aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Orling <timothy.t.orling@intel.com>2021-11-25 17:53:22 -0800
committerTim Orling <timothy.t.orling@intel.com>2021-11-25 20:16:13 -0800
commit7967250b8b7c22b80fa8cbe84a776ff28ea26b1a (patch)
tree4bb821b7cb7db98db41243d45dcc4b945182d1bc
parent9e4370858bcb3f91f2e013911d92b32be09aec23 (diff)
downloadopenembedded-core-contrib-7967250b8b7c22b80fa8cbe84a776ff28ea26b1a.tar.gz
openembedded-core-contrib-7967250b8b7c22b80fa8cbe84a776ff28ea26b1a.tar.bz2
openembedded-core-contrib-7967250b8b7c22b80fa8cbe84a776ff28ea26b1a.zip
python3: refactor python-config patch
Drop legacy python-config.patch distutils is deprecated in Python 3.10 and will be removed in Python 3.12 (~October 2023). Rather than wholesale import the distutils.sysconfig module, refactor to replicate legacy distutils usage that we need. This merges changes to get_python_inc from 12-distutils-prefix-is-inside-staging-area.patch [YOCTO #14610] Signed-off-by: Tim Orling <timothy.t.orling@intel.com>
-rw-r--r--meta/recipes-devtools/python/python3/0001-python-config.in-implement-legacy-disutils-behavior.patch68
-rw-r--r--meta/recipes-devtools/python/python3/python-config.patch55
-rw-r--r--meta/recipes-devtools/python/python3_3.10.0.bb2
3 files changed, 69 insertions, 56 deletions
diff --git a/meta/recipes-devtools/python/python3/0001-python-config.in-implement-legacy-disutils-behavior.patch b/meta/recipes-devtools/python/python3/0001-python-config.in-implement-legacy-disutils-behavior.patch
new file mode 100644
index 0000000000..71fad65def
--- /dev/null
+++ b/meta/recipes-devtools/python/python3/0001-python-config.in-implement-legacy-disutils-behavior.patch
@@ -0,0 +1,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
+
diff --git a/meta/recipes-devtools/python/python3/python-config.patch b/meta/recipes-devtools/python/python3/python-config.patch
deleted file mode 100644
index c53f646af3..0000000000
--- a/meta/recipes-devtools/python/python3/python-config.patch
+++ /dev/null
@@ -1,55 +0,0 @@
-From 57d073c12e7bede29919117b0141df14015eb27f Mon Sep 17 00:00:00 2001
-From: Tyler Hall <tylerwhall@gmail.com>
-Date: Sun, 4 May 2014 20:06:43 -0400
-Subject: [PATCH] python-config: Revert to using distutils.sysconfig
-
-The newer sysconfig module shares some code with distutils.sysconfig, but the same modifications as in
-
-12-distutils-prefix-is-inside-staging-area.patch makes distutils.sysconfig
-
-affect the native runtime as well as cross building. Use the old, patched
-implementation which returns paths in the staging directory and for the target,
-as appropriate.
-
-Upstream-Status: Inappropriate [Embedded Specific]
-
-Signed-off-by: Tyler Hall <tylerwhall@gmail.com>
-
----
- Misc/python-config.in | 10 +++++-----
- 1 file changed, 5 insertions(+), 5 deletions(-)
-
-diff --git a/Misc/python-config.in b/Misc/python-config.in
-index ebd99da..13e57ae 100644
---- a/Misc/python-config.in
-+++ b/Misc/python-config.in
-@@ -6,7 +6,9 @@
- import getopt
- import os
- import sys
--import sysconfig
-+import warnings
-+warnings.filterwarnings("ignore", category=DeprecationWarning)
-+from distutils import sysconfig
-
- valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
- 'ldflags', 'extension-suffix', 'help', 'abiflags', 'configdir',
-@@ -35,14 +35,14 @@ if '--help' in opt_flags:
-
- for opt in opt_flags:
- if opt == '--prefix':
-- print(getvar('prefix'))
-+ print(sysconfig.PREFIX)
-
- elif opt == '--exec-prefix':
-- print(getvar('exec_prefix'))
-+ print(sysconfig.EXEC_PREFIX)
-
- elif opt in ('--includes', '--cflags'):
-- flags = ['-I' + sysconfig.get_path('include'),
-- '-I' + sysconfig.get_path('platinclude')]
-+ flags = ['-I' + sysconfig.get_python_inc(),
-+ '-I' + sysconfig.get_python_inc(plat_specific=True)]
- if opt == '--cflags':
- flags.extend(getvar('CFLAGS').split())
- print(' '.join(flags))
diff --git a/meta/recipes-devtools/python/python3_3.10.0.bb b/meta/recipes-devtools/python/python3_3.10.0.bb
index e3300b6495..6b965af050 100644
--- a/meta/recipes-devtools/python/python3_3.10.0.bb
+++ b/meta/recipes-devtools/python/python3_3.10.0.bb
@@ -17,7 +17,6 @@ SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \
file://0001-Do-not-add-usr-lib-termcap-to-linker-flags-to-avoid-.patch \
${@bb.utils.contains('PACKAGECONFIG', 'tk', '', 'file://avoid_warning_about_tkinter.patch', d)} \
file://0001-Do-not-use-the-shell-version-of-python-config-that-w.patch \
- file://python-config.patch \
file://0001-Makefile.pre-use-qemu-wrapper-when-gathering-profile.patch \
file://0001-python3-use-cc_basename-to-replace-CC-for-checking-c.patch \
file://0001-bpo-36852-proper-detection-of-mips-architecture-for-.patch \
@@ -33,6 +32,7 @@ SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \
file://makerace.patch \
file://0001-sysconfig.py-use-platlibdir-also-for-purelib.patch \
file://0001-Lib-pty.py-handle-stdin-I-O-errors-same-way-as-maste.patch \
+ file://0001-python-config.in-implement-legacy-disutils-behavior.patch \
"
SRC_URI:append:class-native = " \