aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-framework/tensorflow/files/0011-fix-python3-include-directory-not-found.patch
blob: d516d707af32024ca223e02ebfff9362be5c597c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
From d15265b01f6247e32ee3793e44ac6d0416e63615 Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
Date: Mon, 14 Nov 2022 15:27:41 +0800
Subject: [PATCH] fix python3 include directory not found

After python3 in Yocto was upgraded to 3.11, the result of
`importlib.import_module('distutils.sysconfig').get_python_inc()'
is not right, but the result of `importlib.import_module('sysconfig').
get_path('include')' is OK

$ ../recipe-sysroot-native/usr/bin/python3-native/python3
>>> import importlib; import importlib.util;
>>> importlib.import_module('distutils.sysconfig').get_python_inc()
'/tmp-glibc/work/x86_64-linux/tensorflow-native/2.10.0-r0/recipe-sysroot-native/tmp-glibc/work/x86_64-linux/tensorflow-native/2.10.0-r0/recipe-sysroot-native/usr/include/python3.11'
>>> importlib.import_module('sysconfig').get_path('include')
'/tmp-glibc/work/x86_64-linux/tensorflow-native/2.10.0-r0/recipe-sysroot-native/usr/include/python3.11'

Upstream-Status: Inappropriate [Yocto specific]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 third_party/py/python_configure.bzl | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/third_party/py/python_configure.bzl b/third_party/py/python_configure.bzl
index 300cbfb6c71..14248233dc1 100644
--- a/third_party/py/python_configure.bzl
+++ b/third_party/py/python_configure.bzl
@@ -155,11 +155,9 @@ def _get_python_include(repository_ctx, python_bin):
             python_bin,
             "-Wignore",
             "-c",
-            "import importlib; " +
-            "import importlib.util; " +
-            "print(importlib.import_module('distutils.sysconfig').get_python_inc() " +
-            "if importlib.util.find_spec('distutils.sysconfig') " +
-            "else importlib.import_module('sysconfig').get_path('include'))",
+            "from __future__ import print_function;" +
+            "import sysconfig;" +
+            "print(sysconfig.get_path('include'))"
         ],
         error_msg = "Problem getting python include path.",
         error_details = ("Is the Python binary path set up right? " +