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>
This commit is contained in:
Alexander Kanavin
2022-11-09 21:21:09 +01:00
committed by Richard Purdie
parent 3c499e21f4
commit 990af746c2
5 changed files with 33 additions and 107 deletions

View File

@@ -1,7 +1,7 @@
From f0c9dec63d452a7cd1e15ea653f4aced281f021c Mon Sep 17 00:00:00 2001
From 78f482b91d94b44a02e02c4580166757119061ea Mon Sep 17 00:00:00 2001
From: Paulo Neves <ptsneves@gmail.com>
Date: Tue, 7 Jun 2022 16:16:41 +0200
Subject: [PATCH 1/1] Avoid shebang overflow on python-config.py
Subject: [PATCH] Avoid shebang overflow on python-config.py
The whole native path may be too big, leading to shebang
overflow. Let's just use the env shebang.
@@ -11,15 +11,16 @@ Denial reason: [1]
Upstream-Status: Denied [distribution]
[1] https://github.com/python/cpython/pull/93760#pullrequestreview-1005365737
---
Makefile.pre.in | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Makefile.pre.in b/Makefile.pre.in
index f0aedb76cb58999427804255da56fa53284d7032..dd88e43114730f7681715777cc76dabb31113176 100644
index 55c7c46..1f6500a 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1638,6 +1638,8 @@ python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh
@@ -2115,6 +2115,8 @@ python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh
@ # Substitution happens here, as the completely-expanded BINDIR
@ # is not available in configure
sed -e "s,@EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config.py
@@ -27,7 +28,4 @@ index f0aedb76cb58999427804255da56fa53284d7032..dd88e43114730f7681715777cc76dabb
+ sed -i -e '1s|^#!.*|#!/usr/bin/env python3|' python-config.py
@ # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR}
LC_ALL=C sed -e 's,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g' < Misc/python-config.sh >python-config
@ # In OpenEmbedded, always use the python version of the script, the shell
--
2.25.1
@ # On Darwin, always use the python version of the script, the shell

View File

@@ -1,36 +0,0 @@
From 2406432449784243b7590009d42bd0e871253b2e Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Tue, 29 Jan 2019 15:03:01 +0100
Subject: [PATCH] Do not use the shell version of python-config that was
introduced in 3.4
Revert instead to the original python version: it has our tweaks and
outputs directories correctly.
Upstream-Status: Inappropriate [oe-specific]
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
Makefile.pre.in | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/Makefile.pre.in b/Makefile.pre.in
index ee85f35..f0aedb7 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1640,12 +1640,9 @@ python-config: $(srcdir)/Misc/python-config.in Misc/python-config.sh
sed -e "s,@EXENAME@,$(BINDIR)/python$(LDVERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config.py
@ # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR}
LC_ALL=C sed -e 's,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g' < Misc/python-config.sh >python-config
- @ # On Darwin, always use the python version of the script, the shell
- @ # version doesn't use the compiler customizations that are provided
- @ # in python (_osx_support.py).
- @if test `uname -s` = Darwin; then \
- cp python-config.py python-config; \
- fi
+ @ # In OpenEmbedded, always use the python version of the script, the shell
+ @ # version is broken in multiple ways, and doesn't return correct directories
+ cp python-config.py python-config
# Install the include files

View File

@@ -1,55 +0,0 @@
From 8632f25ac4e2c53a3c2c8a1b4fc97fc86e8aad5a 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 | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/Misc/python-config.in b/Misc/python-config.in
index ebd99da..0492e08 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 +37,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))