summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2022-11-09 21:21:09 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-12-07 14:56:54 +0000
commit990af746c250dcb1b7b46e0c887e2ccf67f67d26 (patch)
treebe448e2636be5044048d0c6f6f566a12e357a4ff
parent3c499e21f4225fdaebbb22582753f736ce7e4a73 (diff)
downloadpoky-990af746c250dcb1b7b46e0c887e2ccf67f67d26.tar.gz
python3: use the standard shell version of python3-config
There is really no reason why we can't: it only needs to be available in two versions (native/target), and the correct one can be picked via PATH priority order. This eliminates two un-upstreamable patches, one of which relies on soon to be removed distutils. (From OE-Core rev: d0145ead0f80ba4bde8e24617a8725f38eda8339) Signed-off-by: Alexander Kanavin <alex@linutronix.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes-recipe/python3targetconfig.bbclass17
-rw-r--r--meta/recipes-devtools/python/python3/0001-Avoid-shebang-overflow-on-python-config.py.patch14
-rw-r--r--meta/recipes-devtools/python/python3/0001-Do-not-use-the-shell-version-of-python-config-that-w.patch36
-rw-r--r--meta/recipes-devtools/python/python3/python-config.patch55
-rw-r--r--meta/recipes-devtools/python/python3_3.11.0.bb18
5 files changed, 33 insertions, 107 deletions
diff --git a/meta/classes-recipe/python3targetconfig.bbclass b/meta/classes-recipe/python3targetconfig.bbclass
index 3f89e5e09e..02fdb0c03f 100644
--- a/meta/classes-recipe/python3targetconfig.bbclass
+++ b/meta/classes-recipe/python3targetconfig.bbclass
@@ -10,26 +10,31 @@ EXTRA_PYTHON_DEPENDS ?= ""
10EXTRA_PYTHON_DEPENDS:class-target = "python3" 10EXTRA_PYTHON_DEPENDS:class-target = "python3"
11DEPENDS:append = " ${EXTRA_PYTHON_DEPENDS}" 11DEPENDS:append = " ${EXTRA_PYTHON_DEPENDS}"
12 12
13do_configure:prepend:class-target() { 13setup_target_config() {
14 export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata" 14 export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
15 export PATH=${STAGING_EXECPREFIXDIR}/python-target-config/:$PATH
16}
17
18do_configure:prepend:class-target() {
19 setup_target_config
15} 20}
16 21
17do_compile:prepend:class-target() { 22do_compile:prepend:class-target() {
18 export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata" 23 setup_target_config
19} 24}
20 25
21do_install:prepend:class-target() { 26do_install:prepend:class-target() {
22 export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata" 27 setup_target_config
23} 28}
24 29
25do_configure:prepend:class-nativesdk() { 30do_configure:prepend:class-nativesdk() {
26 export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata" 31 setup_target_config
27} 32}
28 33
29do_compile:prepend:class-nativesdk() { 34do_compile:prepend:class-nativesdk() {
30 export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata" 35 setup_target_config
31} 36}
32 37
33do_install:prepend:class-nativesdk() { 38do_install:prepend:class-nativesdk() {
34 export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata" 39 setup_target_config
35} 40}
diff --git a/meta/recipes-devtools/python/python3/0001-Avoid-shebang-overflow-on-python-config.py.patch b/meta/recipes-devtools/python/python3/0001-Avoid-shebang-overflow-on-python-config.py.patch
index 921da8de7c..db08435004 100644
--- a/meta/recipes-devtools/python/python3/0001-Avoid-shebang-overflow-on-python-config.py.patch
+++ b/meta/recipes-devtools/python/python3/0001-Avoid-shebang-overflow-on-python-config.py.patch
@@ -1,7 +1,7 @@
1From f0c9dec63d452a7cd1e15ea653f4aced281f021c Mon Sep 17 00:00:00 2001 1From 78f482b91d94b44a02e02c4580166757119061ea Mon Sep 17 00:00:00 2001
2From: Paulo Neves <ptsneves@gmail.com> 2From: Paulo Neves <ptsneves@gmail.com>
3Date: Tue, 7 Jun 2022 16:16:41 +0200 3Date: Tue, 7 Jun 2022 16:16:41 +0200
4Subject: [PATCH 1/1] Avoid shebang overflow on python-config.py 4Subject: [PATCH] Avoid shebang overflow on python-config.py
5 5
6The whole native path may be too big, leading to shebang 6The whole native path may be too big, leading to shebang
7overflow. Let's just use the env shebang. 7overflow. Let's just use the env shebang.
@@ -11,15 +11,16 @@ Denial reason: [1]
11Upstream-Status: Denied [distribution] 11Upstream-Status: Denied [distribution]
12 12
13[1] https://github.com/python/cpython/pull/93760#pullrequestreview-1005365737 13[1] https://github.com/python/cpython/pull/93760#pullrequestreview-1005365737
14
14--- 15---
15 Makefile.pre.in | 2 ++ 16 Makefile.pre.in | 2 ++
16 1 file changed, 2 insertions(+) 17 1 file changed, 2 insertions(+)
17 18
18diff --git a/Makefile.pre.in b/Makefile.pre.in 19diff --git a/Makefile.pre.in b/Makefile.pre.in
19index f0aedb76cb58999427804255da56fa53284d7032..dd88e43114730f7681715777cc76dabb31113176 100644 20index 55c7c46..1f6500a 100644
20--- a/Makefile.pre.in 21--- a/Makefile.pre.in
21+++ b/Makefile.pre.in 22+++ b/Makefile.pre.in
22@@ -1638,6 +1638,8 @@ python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh 23@@ -2115,6 +2115,8 @@ python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh
23 @ # Substitution happens here, as the completely-expanded BINDIR 24 @ # Substitution happens here, as the completely-expanded BINDIR
24 @ # is not available in configure 25 @ # is not available in configure
25 sed -e "s,@EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config.py 26 sed -e "s,@EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config.py
@@ -27,7 +28,4 @@ index f0aedb76cb58999427804255da56fa53284d7032..dd88e43114730f7681715777cc76dabb
27+ sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' python-config.py 28+ sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' python-config.py
28 @ # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR} 29 @ # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR}
29 LC_ALL=C sed -e 's,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g' < Misc/python-config.sh >python-config 30 LC_ALL=C sed -e 's,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g' < Misc/python-config.sh >python-config
30 @ # In OpenEmbedded, always use the python version of the script, the shell 31 @ # On Darwin, always use the python version of the script, the shell
31--
322.25.1
33
diff --git a/meta/recipes-devtools/python/python3/0001-Do-not-use-the-shell-version-of-python-config-that-w.patch b/meta/recipes-devtools/python/python3/0001-Do-not-use-the-shell-version-of-python-config-that-w.patch
deleted file mode 100644
index d98f243cb1..0000000000
--- a/meta/recipes-devtools/python/python3/0001-Do-not-use-the-shell-version-of-python-config-that-w.patch
+++ /dev/null
@@ -1,36 +0,0 @@
1From 2406432449784243b7590009d42bd0e871253b2e Mon Sep 17 00:00:00 2001
2From: Alexander Kanavin <alex.kanavin@gmail.com>
3Date: Tue, 29 Jan 2019 15:03:01 +0100
4Subject: [PATCH] Do not use the shell version of python-config that was
5 introduced in 3.4
6
7Revert instead to the original python version: it has our tweaks and
8outputs directories correctly.
9
10Upstream-Status: Inappropriate [oe-specific]
11Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
12
13---
14 Makefile.pre.in | 9 +++------
15 1 file changed, 3 insertions(+), 6 deletions(-)
16
17diff --git a/Makefile.pre.in b/Makefile.pre.in
18index ee85f35..f0aedb7 100644
19--- a/Makefile.pre.in
20+++ b/Makefile.pre.in
21@@ -1640,12 +1640,9 @@ python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh
22 sed -e "s,@EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config.py
23 @ # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR}
24 LC_ALL=C sed -e 's,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g' < Misc/python-config.sh >python-config
25- @ # On Darwin, always use the python version of the script, the shell
26- @ # version doesn't use the compiler customizations that are provided
27- @ # in python (_osx_support.py).
28- @if test `uname -s` = Darwin; then \
29- cp python-config.py python-config; \
30- fi
31+ @ # In OpenEmbedded, always use the python version of the script, the shell
32+ @ # version is broken in multiple ways, and doesn't return correct directories
33+ cp python-config.py python-config
34
35
36 # Install the include files
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 4da399e46e..0000000000
--- a/meta/recipes-devtools/python/python3/python-config.patch
+++ /dev/null
@@ -1,55 +0,0 @@
1From 8632f25ac4e2c53a3c2c8a1b4fc97fc86e8aad5a Mon Sep 17 00:00:00 2001
2From: Tyler Hall <tylerwhall@gmail.com>
3Date: Sun, 4 May 2014 20:06:43 -0400
4Subject: [PATCH] python-config: Revert to using distutils.sysconfig
5
6The newer sysconfig module shares some code with distutils.sysconfig, but the same modifications as in
7
812-distutils-prefix-is-inside-staging-area.patch makes distutils.sysconfig
9
10affect the native runtime as well as cross building. Use the old, patched
11implementation which returns paths in the staging directory and for the target,
12as appropriate.
13
14Upstream-Status: Inappropriate [Embedded Specific]
15
16Signed-off-by: Tyler Hall <tylerwhall@gmail.com>
17
18---
19 Misc/python-config.in | 12 +++++++-----
20 1 file changed, 7 insertions(+), 5 deletions(-)
21
22diff --git a/Misc/python-config.in b/Misc/python-config.in
23index ebd99da..0492e08 100644
24--- a/Misc/python-config.in
25+++ b/Misc/python-config.in
26@@ -6,7 +6,9 @@
27 import getopt
28 import os
29 import sys
30-import sysconfig
31+import warnings
32+warnings.filterwarnings("ignore", category=DeprecationWarning)
33+from distutils import sysconfig
34
35 valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
36 'ldflags', 'extension-suffix', 'help', 'abiflags', 'configdir',
37@@ -35,14 +37,14 @@ if '--help' in opt_flags:
38
39 for opt in opt_flags:
40 if opt == '--prefix':
41- print(getvar('prefix'))
42+ print(sysconfig.PREFIX)
43
44 elif opt == '--exec-prefix':
45- print(getvar('exec_prefix'))
46+ print(sysconfig.EXEC_PREFIX)
47
48 elif opt in ('--includes', '--cflags'):
49- flags = ['-I' + sysconfig.get_path('include'),
50- '-I' + sysconfig.get_path('platinclude')]
51+ flags = ['-I' + sysconfig.get_python_inc(),
52+ '-I' + sysconfig.get_python_inc(plat_specific=True)]
53 if opt == '--cflags':
54 flags.extend(getvar('CFLAGS').split())
55 print(' '.join(flags))
diff --git a/meta/recipes-devtools/python/python3_3.11.0.bb b/meta/recipes-devtools/python/python3_3.11.0.bb
index c4fa8c65cd..abcfc3ec32 100644
--- a/meta/recipes-devtools/python/python3_3.11.0.bb
+++ b/meta/recipes-devtools/python/python3_3.11.0.bb
@@ -16,8 +16,6 @@ SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \
16 file://cgi_py.patch \ 16 file://cgi_py.patch \
17 file://0001-Do-not-add-usr-lib-termcap-to-linker-flags-to-avoid-.patch \ 17 file://0001-Do-not-add-usr-lib-termcap-to-linker-flags-to-avoid-.patch \
18 ${@bb.utils.contains('PACKAGECONFIG', 'tk', '', 'file://avoid_warning_about_tkinter.patch', d)} \ 18 ${@bb.utils.contains('PACKAGECONFIG', 'tk', '', 'file://avoid_warning_about_tkinter.patch', d)} \
19 file://0001-Do-not-use-the-shell-version-of-python-config-that-w.patch \
20 file://python-config.patch \
21 file://0001-Makefile.pre-use-qemu-wrapper-when-gathering-profile.patch \ 19 file://0001-Makefile.pre-use-qemu-wrapper-when-gathering-profile.patch \
22 file://0001-python3-use-cc_basename-to-replace-CC-for-checking-c.patch \ 20 file://0001-python3-use-cc_basename-to-replace-CC-for-checking-c.patch \
23 file://0001-bpo-36852-proper-detection-of-mips-architecture-for-.patch \ 21 file://0001-bpo-36852-proper-detection-of-mips-architecture-for-.patch \
@@ -175,6 +173,9 @@ do_install:append:class-native() {
175 173
176 # disable the lookup in user's site-packages globally 174 # disable the lookup in user's site-packages globally
177 sed -i 's#ENABLE_USER_SITE = None#ENABLE_USER_SITE = False#' ${D}${libdir}/python${PYTHON_MAJMIN}/site.py 175 sed -i 's#ENABLE_USER_SITE = None#ENABLE_USER_SITE = False#' ${D}${libdir}/python${PYTHON_MAJMIN}/site.py
176
177 # python3-config needs to be in /usr/bin and not in a subdir of it to work properly
178 mv ${D}/${bindir}/${PN}/python*config ${D}/${bindir}/
178} 179}
179 180
180do_install:append() { 181do_install:append() {
@@ -223,6 +224,19 @@ do_install:append:class-nativesdk () {
223 create_wrapper ${D}${bindir}/python${PYTHON_MAJMIN} TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo' PYTHONNOUSERSITE='1' 224 create_wrapper ${D}${bindir}/python${PYTHON_MAJMIN} TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo' PYTHONNOUSERSITE='1'
224} 225}
225 226
227SYSROOT_PREPROCESS_FUNCS:append:class-target = " provide_target_config_script"
228SYSROOT_PREPROCESS_FUNCS:append:class-nativesdk = " provide_target_config_script"
229
230# This is installed into /usr/python-target-config/ and not /usr/bin
231# because adding target sysroot's /usr/bin/ to PATH has unwanted side effects
232# in components erroneously picking up other target executables from it
233provide_target_config_script() {
234 install -d ${SYSROOT_DESTDIR}${prefix}/python-target-config/
235 install ${D}/${bindir}/python3-config ${SYSROOT_DESTDIR}/${prefix}/python-target-config/
236 install ${D}/${bindir}/python${PYTHON_MAJMIN}-config ${SYSROOT_DESTDIR}/${prefix}/python-target-config/
237}
238SYSROOT_DIRS += "${prefix}/python-target-config/"
239
226SSTATE_SCAN_FILES += "Makefile _sysconfigdata.py" 240SSTATE_SCAN_FILES += "Makefile _sysconfigdata.py"
227SSTATE_HASHEQUIV_FILEMAP = " \ 241SSTATE_HASHEQUIV_FILEMAP = " \
228 populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${TMPDIR} \ 242 populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${TMPDIR} \