From fae4ba632bc739cdf7369659f9b3bea2dd1cde45 Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Mon, 11 Oct 2021 11:40:40 +0200 Subject: python3: update 3.9.7 -> 3.10.0 native and target 0001-Lib-sysconfig.py-use-libdir-values-from-configuratio.patch replaced by native-only 0001-Lib-sysconfig.py-use-prefix-value-from-build-configu.patch which is more reboust against upstream changes, and keeps target code unmodified. This however necessitated adding 0001-sysconfig.py-use-platlibdir-also-for-purelib.patch to avoid hardcoding 'lib' on target builds as libdir. Drop chunk from 0001-distutils-sysconfig-append-STAGING_LIBDIR-python-sys.patch as upstream now uses sysconfig directly inside distutils. Add 0001-Lib-pty.py-handle-stdin-I-O-errors-same-way-as-maste.patch and 0001-multiprocessing-disable-a-failing-test.patch to address ptest failures. License-Update: copyright years, case corrections. (From OE-Core rev: 72a75043a946f7db01d3ec04c8889e055f542cca) Signed-off-by: Alexander Kanavin Signed-off-by: Alexandre Belloni Signed-off-by: Richard Purdie --- meta/classes/python3-dir.bbclass | 2 +- ...Don-t-search-system-for-headers-libraries.patch | 6 +- ...handle-stdin-I-O-errors-same-way-as-maste.patch | 49 +++ ...ig.py-use-libdir-values-from-configuratio.patch | 35 -- ...ig.py-use-prefix-value-from-build-configu.patch | 34 ++ ...ysconfig-append-STAGING_LIBDIR-python-sys.patch | 24 +- ...ss-missing-libraries-to-Extension-for-mul.patch | 15 +- ...config.py-use-platlibdir-also-for-purelib.patch | 30 ++ ...2-distutils-prefix-is-inside-staging-area.patch | 14 +- .../recipes-devtools/python/python3/makerace.patch | 25 +- meta/recipes-devtools/python/python3_3.10.0.bb | 404 +++++++++++++++++++++ meta/recipes-devtools/python/python3_3.9.7.bb | 402 -------------------- 12 files changed, 558 insertions(+), 482 deletions(-) create mode 100644 meta/recipes-devtools/python/python3/0001-Lib-pty.py-handle-stdin-I-O-errors-same-way-as-maste.patch delete mode 100644 meta/recipes-devtools/python/python3/0001-Lib-sysconfig.py-use-libdir-values-from-configuratio.patch create mode 100644 meta/recipes-devtools/python/python3/0001-Lib-sysconfig.py-use-prefix-value-from-build-configu.patch create mode 100644 meta/recipes-devtools/python/python3/0001-sysconfig.py-use-platlibdir-also-for-purelib.patch create mode 100644 meta/recipes-devtools/python/python3_3.10.0.bb delete mode 100644 meta/recipes-devtools/python/python3_3.9.7.bb diff --git a/meta/classes/python3-dir.bbclass b/meta/classes/python3-dir.bbclass index f51f971fc5..ff03e584d4 100644 --- a/meta/classes/python3-dir.bbclass +++ b/meta/classes/python3-dir.bbclass @@ -1,4 +1,4 @@ -PYTHON_BASEVERSION = "3.9" +PYTHON_BASEVERSION = "3.10" PYTHON_ABI = "" PYTHON_DIR = "python${PYTHON_BASEVERSION}" PYTHON_PN = "python3" diff --git a/meta/recipes-devtools/python/python3/0001-Don-t-search-system-for-headers-libraries.patch b/meta/recipes-devtools/python/python3/0001-Don-t-search-system-for-headers-libraries.patch index a94fa0a5a9..46179ba1d1 100644 --- a/meta/recipes-devtools/python/python3/0001-Don-t-search-system-for-headers-libraries.patch +++ b/meta/recipes-devtools/python/python3/0001-Don-t-search-system-for-headers-libraries.patch @@ -1,4 +1,4 @@ -From 9da913bf5f39c6fe737219af7419170574d6fbfb Mon Sep 17 00:00:00 2001 +From cebb772d718a8f798ed5ae311a6e3e61534bea95 Mon Sep 17 00:00:00 2001 From: Jeremy Puhlman Date: Wed, 4 Mar 2020 00:06:42 +0000 Subject: [PATCH] Don't search system for headers/libraries @@ -11,10 +11,10 @@ Signed-off-by: Jeremy Puhlman 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py -index a0bf9ea..da099bf 100644 +index 95e3e11..32a4d42 100644 --- a/setup.py +++ b/setup.py -@@ -674,8 +674,8 @@ class PyBuildExt(build_ext): +@@ -840,8 +840,8 @@ class PyBuildExt(build_ext): add_dir_to_list(self.compiler.include_dirs, sysconfig.get_config_var("INCLUDEDIR")) diff --git a/meta/recipes-devtools/python/python3/0001-Lib-pty.py-handle-stdin-I-O-errors-same-way-as-maste.patch b/meta/recipes-devtools/python/python3/0001-Lib-pty.py-handle-stdin-I-O-errors-same-way-as-maste.patch new file mode 100644 index 0000000000..d6aa9501a7 --- /dev/null +++ b/meta/recipes-devtools/python/python3/0001-Lib-pty.py-handle-stdin-I-O-errors-same-way-as-maste.patch @@ -0,0 +1,49 @@ +From d8521ee967937184eadc59fff1a30740ad181a98 Mon Sep 17 00:00:00 2001 +From: Alexander Kanavin +Date: Thu, 16 Sep 2021 16:35:37 +0200 +Subject: [PATCH] Lib/pty.py: handle stdin I/O errors same way as master I/O + errors + +reading stdin can throw the same I/O errors as reading from master fd does, +e.g. when running under Yocto's test harness: +====================================================================== +ERROR: test_spawn_doesnt_hang (test.test_pty.PtyTest) +---------------------------------------------------------------------- +Traceback (most recent call last): + File "/usr/lib/python3.10/test/test_pty.py", line 316, in test_spawn_doesnt_hang + pty.spawn([sys.executable, '-c', 'print("hi there")']) + File "/usr/lib/python3.10/pty.py", line 181, in spawn + _copy(master_fd, master_read, stdin_read) + File "/usr/lib/python3.10/pty.py", line 157, in _copy + data = stdin_read(STDIN_FILENO) + File "/usr/lib/python3.10/pty.py", line 132, in _read + return os.read(fd, 1024) +OSError: [Errno 5] Input/output error + +So let's treat both channels the same. + +Upstream-Status: Submitted [https://github.com/python/cpython/pull/28388] +Signed-off-by: Alexander Kanavin +--- + Lib/pty.py | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/Lib/pty.py b/Lib/pty.py +index 8d8ce40df5..35439c6b96 100644 +--- a/Lib/pty.py ++++ b/Lib/pty.py +@@ -154,7 +154,10 @@ def _copy(master_fd, master_read=_read, stdin_read=_read): + os.write(STDOUT_FILENO, data) + + if STDIN_FILENO in rfds: +- data = stdin_read(STDIN_FILENO) ++ try: ++ data = stdin_read(STDIN_FILENO) ++ except OSError: ++ data = b"" + if not data: + fds.remove(STDIN_FILENO) + else: +-- +2.20.1 + diff --git a/meta/recipes-devtools/python/python3/0001-Lib-sysconfig.py-use-libdir-values-from-configuratio.patch b/meta/recipes-devtools/python/python3/0001-Lib-sysconfig.py-use-libdir-values-from-configuratio.patch deleted file mode 100644 index 1490cdbb18..0000000000 --- a/meta/recipes-devtools/python/python3/0001-Lib-sysconfig.py-use-libdir-values-from-configuratio.patch +++ /dev/null @@ -1,35 +0,0 @@ -From deeedd1b8799294ab276ab7dbbfdb59c1dacc9a2 Mon Sep 17 00:00:00 2001 -From: Alexander Kanavin -Date: Thu, 22 Oct 2020 13:10:34 +0200 -Subject: [PATCH] Lib/sysconfig.py: use libdir values from configuration file - -This allows correctly substituting them for target installs using -native python. - -Signed-off-by: Alexander Kanavin ---- - Lib/sysconfig.py | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py -index bf04ac5..ed0462b 100644 ---- a/Lib/sysconfig.py -+++ b/Lib/sysconfig.py -@@ -20,10 +20,10 @@ __all__ = [ - - _INSTALL_SCHEMES = { - 'posix_prefix': { -- 'stdlib': '{installed_base}/{platlibdir}/python{py_version_short}', -- 'platstdlib': '{platbase}/{platlibdir}/python{py_version_short}', -- 'purelib': '{base}/lib/python{py_version_short}/site-packages', -- 'platlib': '{platbase}/{platlibdir}/python{py_version_short}/site-packages', -+ 'stdlib': '{LIBDEST}', -+ 'platstdlib': '{LIBDEST}', -+ 'purelib': '{LIBDEST}/site-packages', -+ 'platlib': '{LIBDEST}/site-packages', - 'include': - '{installed_base}/include/python{py_version_short}{abiflags}', - 'platinclude': --- -2.24.0 - diff --git a/meta/recipes-devtools/python/python3/0001-Lib-sysconfig.py-use-prefix-value-from-build-configu.patch b/meta/recipes-devtools/python/python3/0001-Lib-sysconfig.py-use-prefix-value-from-build-configu.patch new file mode 100644 index 0000000000..b72c709130 --- /dev/null +++ b/meta/recipes-devtools/python/python3/0001-Lib-sysconfig.py-use-prefix-value-from-build-configu.patch @@ -0,0 +1,34 @@ +From aceaa16e25a8ab6a00f906c340843999635c8e23 Mon Sep 17 00:00:00 2001 +From: Alexander Kanavin +Date: Fri, 10 Sep 2021 12:28:31 +0200 +Subject: [PATCH] Lib/sysconfig.py: use prefix value from build configuration + file + +This allows correctly substituting them for target installs using +native python. + +Upstream-Status: Inappropriate [oe-core cross builds] +Signed-off-by: Alexander Kanavin +--- + Lib/sysconfig.py | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py +index 95b48f6..84f6427 100644 +--- a/Lib/sysconfig.py ++++ b/Lib/sysconfig.py +@@ -613,6 +613,11 @@ def get_config_vars(*args): + _init_non_posix(_CONFIG_VARS) + if os.name == 'posix': + _init_posix(_CONFIG_VARS) ++ _CONFIG_VARS['installed_base'] = _CONFIG_VARS['prefix'] ++ _CONFIG_VARS['base'] = _CONFIG_VARS['prefix'] ++ _CONFIG_VARS['installed_platbase'] = _CONFIG_VARS['prefix'] ++ _CONFIG_VARS['platbase'] = _CONFIG_VARS['prefix'] ++ _CONFIG_VARS['platlibdir'] = _CONFIG_VARS['PLATLIBDIR'] + # For backward compatibility, see issue19555 + SO = _CONFIG_VARS.get('EXT_SUFFIX') + if SO is not None: +-- +2.20.1 + diff --git a/meta/recipes-devtools/python/python3/0001-distutils-sysconfig-append-STAGING_LIBDIR-python-sys.patch b/meta/recipes-devtools/python/python3/0001-distutils-sysconfig-append-STAGING_LIBDIR-python-sys.patch index b982691b36..b323ed4dd0 100644 --- a/meta/recipes-devtools/python/python3/0001-distutils-sysconfig-append-STAGING_LIBDIR-python-sys.patch +++ b/meta/recipes-devtools/python/python3/0001-distutils-sysconfig-append-STAGING_LIBDIR-python-sys.patch @@ -1,4 +1,4 @@ -From e65bfe22c858872b08366aff49119d4145a77f40 Mon Sep 17 00:00:00 2001 +From 3a98c2eab187289dc8c55e36738c2c0f4216d906 Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Thu, 31 Jan 2019 16:46:30 +0100 Subject: [PATCH] distutils/sysconfig: append @@ -10,28 +10,14 @@ Upstream-Status: Inappropriate [oe-core specific] Signed-off-by: Alexander Kanavin --- - Lib/distutils/sysconfig.py | 2 ++ - Lib/sysconfig.py | 2 ++ - 2 files changed, 4 insertions(+) + Lib/sysconfig.py | 2 ++ + 1 file changed, 2 insertions(+) -diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py -index b51629e..2df348c 100644 ---- a/Lib/distutils/sysconfig.py -+++ b/Lib/distutils/sysconfig.py -@@ -438,6 +438,8 @@ def _init_posix(): - platform=sys.platform, - multiarch=getattr(sys.implementation, '_multiarch', ''), - )) -+ if 'STAGING_LIBDIR' in os.environ: -+ sys.path.append(os.environ['STAGING_LIBDIR']+'/python-sysconfigdata') - _temp = __import__(name, globals(), locals(), ['build_time_vars'], 0) - build_time_vars = _temp.build_time_vars - global _config_vars diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py -index b2d790b..405273c 100644 +index a78c0b1..f5c5efe 100644 --- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py -@@ -419,6 +419,8 @@ def _init_posix(vars): +@@ -474,6 +474,8 @@ def _init_posix(vars): """Initialize the module as appropriate for POSIX systems.""" # _sysconfigdata is generated at build time, see _generate_posix_vars() name = _get_sysconfigdata_name() diff --git a/meta/recipes-devtools/python/python3/0001-setup.py-pass-missing-libraries-to-Extension-for-mul.patch b/meta/recipes-devtools/python/python3/0001-setup.py-pass-missing-libraries-to-Extension-for-mul.patch index ea0af02e72..374433c68e 100644 --- a/meta/recipes-devtools/python/python3/0001-setup.py-pass-missing-libraries-to-Extension-for-mul.patch +++ b/meta/recipes-devtools/python/python3/0001-setup.py-pass-missing-libraries-to-Extension-for-mul.patch @@ -1,4 +1,4 @@ -From 7019ba184b828ed7253750cf409fc5760ef90a54 Mon Sep 17 00:00:00 2001 +From bad7e6a625436402a01d03021fb9ccd58bc9930f Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Thu, 9 Jan 2020 17:44:05 +0100 Subject: [PATCH] setup.py: pass missing libraries to Extension for @@ -50,20 +50,21 @@ Upstream-Status: Pending Signed-off-by: Hongxu Jia Signed-off-by: Alexander Kanavin + --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py -index ec3f2a4..b0f1541 100644 +index d92face..f42bcbb 100644 --- a/setup.py +++ b/setup.py -@@ -1671,7 +1671,7 @@ class PyBuildExt(build_ext): - libraries=libs, - include_dirs=["Modules/_multiprocessing"])) - +@@ -1836,7 +1836,7 @@ class PyBuildExt(build_ext): + if (sysconfig.get_config_var('HAVE_SEM_OPEN') and not + sysconfig.get_config_var('POSIX_SEMAPHORES_NOT_ENABLED')): + multiprocessing_srcs.append('_multiprocessing/semaphore.c') - self.add(Extension('_multiprocessing', multiprocessing_srcs, + self.add(Extension('_multiprocessing', multiprocessing_srcs, libraries=['pthread'], include_dirs=["Modules/_multiprocessing"])) - def detect_uuid(self): + if (not MS_WINDOWS and diff --git a/meta/recipes-devtools/python/python3/0001-sysconfig.py-use-platlibdir-also-for-purelib.patch b/meta/recipes-devtools/python/python3/0001-sysconfig.py-use-platlibdir-also-for-purelib.patch new file mode 100644 index 0000000000..2b5a7d308c --- /dev/null +++ b/meta/recipes-devtools/python/python3/0001-sysconfig.py-use-platlibdir-also-for-purelib.patch @@ -0,0 +1,30 @@ +From 93346d1a2f5d4f7085391bc7c1230d85ebe00606 Mon Sep 17 00:00:00 2001 +From: Alexander Kanavin +Date: Sun, 12 Sep 2021 21:44:36 +0200 +Subject: [PATCH] sysconfig.py: use platlibdir also for purelib + +This is needed in multilib configurations where hardcoding 'lib' +is not correct. + +Upstream-Status: Inappropriate [oe-core specific] +Signed-off-by: Alexander Kanavin +--- + Lib/sysconfig.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py +index b70d392..c418acd 100644 +--- a/Lib/sysconfig.py ++++ b/Lib/sysconfig.py +@@ -27,7 +27,7 @@ _INSTALL_SCHEMES = { + 'posix_prefix': { + 'stdlib': '{installed_base}/{platlibdir}/python{py_version_short}', + 'platstdlib': '{platbase}/{platlibdir}/python{py_version_short}', +- 'purelib': '{base}/lib/python{py_version_short}/site-packages', ++ 'purelib': '{base}/{platlibdir}/python{py_version_short}/site-packages', + 'platlib': '{platbase}/{platlibdir}/python{py_version_short}/site-packages', + 'include': + '{installed_base}/include/python{py_version_short}{abiflags}', +-- +2.20.1 + diff --git a/meta/recipes-devtools/python/python3/12-distutils-prefix-is-inside-staging-area.patch b/meta/recipes-devtools/python/python3/12-distutils-prefix-is-inside-staging-area.patch index 5a39cf8933..cc64e3ecf7 100644 --- a/meta/recipes-devtools/python/python3/12-distutils-prefix-is-inside-staging-area.patch +++ b/meta/recipes-devtools/python/python3/12-distutils-prefix-is-inside-staging-area.patch @@ -1,7 +1,7 @@ -From c52fa7948ef109db1132fdc1aee0b68f8d767b4e Mon Sep 17 00:00:00 2001 +From f6411021856bafedd784748ec33494151e783b51 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Tue, 14 May 2013 15:00:26 -0700 -Subject: [PATCH 1/2] python3: Add target and native recipes +Subject: [PATCH] python3: Add target and native recipes Upstream-Status: Inappropriate [embedded specific] @@ -17,10 +17,10 @@ Signed-off-by: Alejandro Hernandez 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py -index 4774e12..ccf7d58 100644 +index 3414a76..361d3a1 100644 --- a/Lib/distutils/sysconfig.py +++ b/Lib/distutils/sysconfig.py -@@ -95,7 +95,9 @@ def get_python_inc(plat_specific=0, prefix=None): +@@ -277,7 +277,9 @@ def get_python_inc(plat_specific=0, prefix=None): If 'prefix' is supplied, use it instead of sys.base_prefix or sys.base_exec_prefix -- i.e., ignore 'plat_specific'. """ @@ -31,7 +31,7 @@ index 4774e12..ccf7d58 100644 prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX if os.name == "posix": if python_build: -@@ -138,7 +140,13 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): +@@ -320,7 +322,13 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): If 'prefix' is supplied, use it instead of sys.base_prefix or sys.base_exec_prefix -- i.e., ignore 'plat_specific'. """ @@ -46,7 +46,7 @@ index 4774e12..ccf7d58 100644 if standard_lib: prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX else: -@@ -152,7 +160,7 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): +@@ -334,7 +342,7 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): else: # Pure Python libdir = "lib" @@ -56,5 +56,5 @@ index 4774e12..ccf7d58 100644 if standard_lib: return libpython -- -2.24.0 +2.20.1 diff --git a/meta/recipes-devtools/python/python3/makerace.patch b/meta/recipes-devtools/python/python3/makerace.patch index 96744cb557..b150c1cb38 100644 --- a/meta/recipes-devtools/python/python3/makerace.patch +++ b/meta/recipes-devtools/python/python3/makerace.patch @@ -1,3 +1,8 @@ +From 8b8583fb4f2bb3421e31ef06d17c04deec431c7e Mon Sep 17 00:00:00 2001 +From: Richard Purdie +Date: Tue, 13 Jul 2021 23:19:29 +0100 +Subject: [PATCH] python3: Fix make race + libainstall installs python-config.py but the .pyc cache files are generated by the libinstall target. This means some builds may not generate the pyc files for python-config.py depending on the order things happen in. This means builds @@ -8,14 +13,18 @@ Add a dependency to avoid the race. Upstream-Status: Pending Signed-off-by: Richard Purdie -Index: Python-3.9.6/Makefile.pre.in -=================================================================== ---- Python-3.9.6.orig/Makefile.pre.in -+++ Python-3.9.6/Makefile.pre.in -@@ -1486,7 +1486,7 @@ LIBSUBDIRS= tkinter tkinter/test tkinter - venv venv/scripts venv/scripts/common venv/scripts/posix \ - curses pydoc_data \ - zoneinfo +--- + Makefile.pre.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile.pre.in b/Makefile.pre.in +index 69d47a2..c471b60 100644 +--- a/Makefile.pre.in ++++ b/Makefile.pre.in +@@ -1528,7 +1528,7 @@ TESTSUBDIRS= ctypes/test \ + unittest/test unittest/test/testmock + + TEST_MODULES=@TEST_MODULES@ -libinstall: build_all $(srcdir)/Modules/xxmodule.c +libinstall: build_all $(srcdir)/Modules/xxmodule.c libainstall @for i in $(SCRIPTDIR) $(LIBDEST); \ diff --git a/meta/recipes-devtools/python/python3_3.10.0.bb b/meta/recipes-devtools/python/python3_3.10.0.bb new file mode 100644 index 0000000000..2e850710b6 --- /dev/null +++ b/meta/recipes-devtools/python/python3_3.10.0.bb @@ -0,0 +1,404 @@ +SUMMARY = "The Python Programming Language" +HOMEPAGE = "http://www.python.org" +DESCRIPTION = "Python is a programming language that lets you work more quickly and integrate your systems more effectively." +LICENSE = "PSFv2" +SECTION = "devel/python" + +LIC_FILES_CHKSUM = "file://LICENSE;md5=3dd7bed622743ef9b77169b3736f7990" + +SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \ + file://run-ptest \ + file://create_manifest3.py \ + file://get_module_deps3.py \ + file://python3-manifest.json \ + file://check_build_completeness.py \ + file://reformat_sysconfig.py \ + file://cgi_py.patch \ + 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 \ + file://crosspythonpath.patch \ + file://0001-Use-FLAG_REF-always-for-interned-strings.patch \ + file://0001-test_locale.py-correct-the-test-output-format.patch \ + file://0017-setup.py-do-not-report-missing-dependencies-for-disa.patch \ + file://0001-setup.py-pass-missing-libraries-to-Extension-for-mul.patch \ + file://0001-Makefile-do-not-compile-.pyc-in-parallel.patch \ + file://0020-configure.ac-setup.py-do-not-add-a-curses-include-pa.patch \ + file://0001-Skip-failing-tests-due-to-load-variability-on-YP-AB.patch \ + file://0001-test_ctypes.test_find-skip-without-tools-sdk.patch \ + 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 \ + " + +SRC_URI:append:class-native = " \ + file://0001-Lib-sysconfig.py-use-prefix-value-from-build-configu.patch \ + file://0001-distutils-sysconfig-append-STAGING_LIBDIR-python-sys.patch \ + file://12-distutils-prefix-is-inside-staging-area.patch \ + file://0001-Don-t-search-system-for-headers-libraries.patch \ + " +SRC_URI[sha256sum] = "5a99f8e7a6a11a7b98b4e75e0d1303d3832cada5534068f69c7b6222a7b1b002" + +# exclude pre-releases for both python 2.x and 3.x +UPSTREAM_CHECK_REGEX = "[Pp]ython-(?P\d+(\.\d+)+).tar" +UPSTREAM_CHECK_URI = "https://www.python.org/downloads/source/" + +CVE_PRODUCT = "python" + +# Upstream consider this expected behaviour +CVE_CHECK_WHITELIST += "CVE-2007-4559" +# This is not exploitable when glibc has CVE-2016-10739 fixed. +CVE_CHECK_WHITELIST += "CVE-2019-18348" + +# This is windows only issue. +CVE_CHECK_WHITELIST += "CVE-2020-15523" + +PYTHON_MAJMIN = "3.10" + +S = "${WORKDIR}/Python-${PV}" + +BBCLASSEXTEND = "native nativesdk" + +inherit autotools pkgconfig qemu ptest multilib_header update-alternatives + +MULTILIB_SUFFIX = "${@d.getVar('base_libdir',1).split('/')[-1]}" + +ALTERNATIVE:${PN}-dev = "python3-config" +ALTERNATIVE_LINK_NAME[python3-config] = "${bindir}/python${PYTHON_MAJMIN}-config" +ALTERNATIVE_TARGET[python3-config] = "${bindir}/python${PYTHON_MAJMIN}-config-${MULTILIB_SUFFIX}" + + +DEPENDS = "bzip2-replacement-native libffi bzip2 openssl sqlite3 zlib virtual/libintl xz virtual/crypt util-linux libtirpc libnsl2 autoconf-archive-native" +DEPENDS:append:class-target = " python3-native" +DEPENDS:append:class-nativesdk = " python3-native" + +# force to use the mutex+cond implementation (https://bugs.python.org/issue41710) +CFLAGS += "-DHAVE_BROKEN_POSIX_SEMAPHORES" + +EXTRA_OECONF = " --without-ensurepip --enable-shared --with-platlibdir=${baselib}" +EXTRA_OECONF:append:class-native = " --bindir=${bindir}/${PN}" + +export CROSSPYTHONPATH="${STAGING_LIBDIR_NATIVE}/python${PYTHON_MAJMIN}/lib-dynload/" + +EXTRANATIVEPATH += "python3-native" + +# LTO will be enabled via packageconfig depending upong distro features +LTO:class-target = "" + +CACHED_CONFIGUREVARS = " \ + ac_cv_file__dev_ptmx=yes \ + ac_cv_file__dev_ptc=no \ + ac_cv_working_tzset=yes \ +" + +def possibly_include_pgo(d): + # PGO currently causes builds to not be reproducible, so disable it for + # now. See YOCTO #13407 + if bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', True, False, d) and d.getVar('BUILD_REPRODUCIBLE_BINARIES') != '1': + return 'pgo' + + return '' + +PACKAGECONFIG:class-target ??= "readline ${@possibly_include_pgo(d)} gdbm ${@bb.utils.filter('DISTRO_FEATURES', 'lto', d)}" +PACKAGECONFIG:class-native ??= "readline gdbm" +PACKAGECONFIG:class-nativesdk ??= "readline gdbm" +PACKAGECONFIG[readline] = ",,readline" +# Use profile guided optimisation by running PyBench inside qemu-user +PACKAGECONFIG[pgo] = "--enable-optimizations,,qemu-native" +PACKAGECONFIG[tk] = ",,tk" +PACKAGECONFIG[gdbm] = ",,gdbm" +PACKAGECONFIG[lto] = "--with-lto,," + +do_configure:prepend () { + mkdir -p ${B}/Modules + cat > ${B}/Modules/Setup.local << EOF +*disabled* +${@bb.utils.contains('PACKAGECONFIG', 'gdbm', '', '_gdbm _dbm', d)} +${@bb.utils.contains('PACKAGECONFIG', 'readline', '', 'readline', d)} +EOF +} + +CPPFLAGS:append = " -I${STAGING_INCDIR}/ncursesw -I${STAGING_INCDIR}/uuid" + +EXTRA_OEMAKE = '\ + STAGING_LIBDIR=${STAGING_LIBDIR} \ + STAGING_INCDIR=${STAGING_INCDIR} \ + LIB=${baselib} \ +' + +do_compile:prepend:class-target() { + if ${@bb.utils.contains('PACKAGECONFIG', 'pgo', 'true', 'false', d)}; then + qemu_binary="${@qemu_wrapper_cmdline(d, '${STAGING_DIR_TARGET}', ['${B}', '${STAGING_DIR_TARGET}/${base_libdir}'])}" + cat >pgo-wrapper < ${B}/Modules/Setup.local << EOF -*disabled* -${@bb.utils.contains('PACKAGECONFIG', 'gdbm', '', '_gdbm _dbm', d)} -${@bb.utils.contains('PACKAGECONFIG', 'readline', '', 'readline', d)} -EOF -} - -CPPFLAGS:append = " -I${STAGING_INCDIR}/ncursesw -I${STAGING_INCDIR}/uuid" - -EXTRA_OEMAKE = '\ - STAGING_LIBDIR=${STAGING_LIBDIR} \ - STAGING_INCDIR=${STAGING_INCDIR} \ - LIB=${baselib} \ -' - -do_compile:prepend:class-target() { - if ${@bb.utils.contains('PACKAGECONFIG', 'pgo', 'true', 'false', d)}; then - qemu_binary="${@qemu_wrapper_cmdline(d, '${STAGING_DIR_TARGET}', ['${B}', '${STAGING_DIR_TARGET}/${base_libdir}'])}" - cat >pgo-wrapper <