summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python3/0001-python-config.in-implement-legacy-disutils-behavior.patch
blob: 71fad65def0b40d251c3e7ac7665804fff2978b9 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
From 9bc5f12a31f1c90913bfa90f71ec12cea95de040 Mon Sep 17 00:00:00 2001
From: Tim Orling <timothy.t.orling@intel.com>
Date: Thu, 25 Nov 2021 17:48:23 -0800
Subject: [PATCH] python-config.in: implement legacy disutils behavior

The sysconfig behavior does not provide the correct paths for our usage,
but rather than continue to use the deprecated distutils.sysconfig
behavior, refactor the code paths we need to use supported standard
library functionality.

[YOCTO #14610]

Upstream-Status: Inappropriate [oe-specific]

Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
---
 Misc/python-config.in | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/Misc/python-config.in b/Misc/python-config.in
index ebd99daa0c..5959d74453 100644
--- a/Misc/python-config.in
+++ b/Misc/python-config.in
@@ -35,14 +35,37 @@ if '--help' in opt_flags:
 
 for opt in opt_flags:
     if opt == '--prefix':
-        print(getvar('prefix'))
+	# borrow the legacy behavior of distutils.sysconfig.PREFIX
+        print(os.path.normpath(sys.prefix))
 
     elif opt == '--exec-prefix':
-        print(getvar('exec_prefix'))
+        # borrow the legacy behavior of distutils.sysconfig.EXEC_PREFIX
+        print(os.path.normpath(sys.exec_prefix))
 
     elif opt in ('--includes', '--cflags'):
-        flags = ['-I' + sysconfig.get_path('include'),
-                 '-I' + sysconfig.get_path('platinclude')]
+        # borrowing the logic from legacy/deprecated distutils.sysconfig.get_python_inc
+
+        # Calculate the build qualifier flags if they are defined.  Adding the flags
+        # to the include and lib directories only makes sense for an installation, not
+        # an in-source build.
+        build_flags = ''
+        try:
+            if not sysconfig._PYTHON_BUILD:
+                build_flags = sys.abiflags
+        except AttributeError:
+            # It's not a configure-based build, so the sys module doesn't have
+            # this attribute, which is fine.
+            pass
+
+        incdir = os.path.join(sysconfig.get_config_var('srcdir'), 'Include')
+        if prefix is None and os.environ.get('STAGING_LIBDIR', "");
+            prefix = os.environ['STAGING_LIBDIR'].rstrip(lib_basename)
+        elif prefix is None:
+            prefix = sysconfig._BASE_EXEC_PREFIX or sysconfig._BASE_PREFIX
+        python_dir = 'python' + sysconfig.get_python_version() + build_flags
+        #platincdir = sysconfig._sys_home or sysconfig._PROJECT_BASE
+        flags = ['-I' + os.path.normpath(incdir),
+                 '-I' + os.path.join(prefix, "include", python_dir)]
         if opt == '--cflags':
             flags.extend(getvar('CFLAGS').split())
         print(' '.join(flags))
-- 
2.30.2