diff mbox series

[46/48] python3: use the standard shell version of python3-config

Message ID 20221107145508.1051404-46-alex@linutronix.de
State New
Headers show
Series [01/48] man-pages: upgrade 5.13 -> 6.01 | expand

Commit Message

Alexander Kanavin Nov. 7, 2022, 2:55 p.m. UTC
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.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 .../python3targetconfig.bbclass               | 17 ++++--
 ...shebang-overflow-on-python-config.py.patch | 14 ++---
 ...hell-version-of-python-config-that-w.patch | 36 ------------
 .../python/python3/python-config.patch        | 55 -------------------
 .../recipes-devtools/python/python3_3.11.0.bb | 15 ++++-
 5 files changed, 30 insertions(+), 107 deletions(-)
 delete mode 100644 meta/recipes-devtools/python/python3/0001-Do-not-use-the-shell-version-of-python-config-that-w.patch
 delete mode 100644 meta/recipes-devtools/python/python3/python-config.patch

Comments

Richard Purdie Nov. 8, 2022, 10:59 p.m. UTC | #1
On Mon, 2022-11-07 at 15:55 +0100, Alexander Kanavin wrote:
>  
> +SYSROOT_PREPROCESS_FUNCS:append:class-target = " provide_target_config_script"
> +SYSROOT_PREPROCESS_FUNCS:append:class-nativesdk = " provide_target_config_script"
> +
> +provide_target_config_script() {
> +        install -d ${SYSROOT_DESTDIR}${bindir}/
> +        install ${D}/${bindir}/python3-config ${SYSROOT_DESTDIR}${bindir}/
> +        install ${D}/${bindir}/python${PYTHON_MAJMIN}-config ${SYSROOT_DESTDIR}${bindir}/
> +}
> +
> +
>  SSTATE_SCAN_FILES += "Makefile _sysconfigdata.py"
>  SSTATE_HASHEQUIV_FILEMAP = " \
>      populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${TMPDIR} \

This made me wonder if we shouldn't have a better way of handling this.
I was wondering if we should have a sysroot_stage_file function (like
sysroot_stage_dir) and then we could do something like:

sysroot_stage_all:append() {
	sysroot_stage_file ${D}/${bindir}/python3-config ${SYSROOT_DESTDIR}/${bindir}/python3-config
}

Note that the sysroot code plays with hardlinks for efficiency, I
appreciate one file doesn't really matter though.

I was hoping we could have just added to SYSROOT_DIRS but that does
only handle dirs, not files.

Cheers,

Richard
Khem Raj Nov. 9, 2022, 3:46 a.m. UTC | #2
I am seeing a bunch of failures perhaps related but not sure

https://errors.yoctoproject.org/Errors/Build/154610/

On Tue, Nov 8, 2022 at 2:59 PM Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
>
> On Mon, 2022-11-07 at 15:55 +0100, Alexander Kanavin wrote:
> >
> > +SYSROOT_PREPROCESS_FUNCS:append:class-target = " provide_target_config_script"
> > +SYSROOT_PREPROCESS_FUNCS:append:class-nativesdk = " provide_target_config_script"
> > +
> > +provide_target_config_script() {
> > +        install -d ${SYSROOT_DESTDIR}${bindir}/
> > +        install ${D}/${bindir}/python3-config ${SYSROOT_DESTDIR}${bindir}/
> > +        install ${D}/${bindir}/python${PYTHON_MAJMIN}-config ${SYSROOT_DESTDIR}${bindir}/
> > +}
> > +
> > +
> >  SSTATE_SCAN_FILES += "Makefile _sysconfigdata.py"
> >  SSTATE_HASHEQUIV_FILEMAP = " \
> >      populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${TMPDIR} \
>
> This made me wonder if we shouldn't have a better way of handling this.
> I was wondering if we should have a sysroot_stage_file function (like
> sysroot_stage_dir) and then we could do something like:
>
> sysroot_stage_all:append() {
>         sysroot_stage_file ${D}/${bindir}/python3-config ${SYSROOT_DESTDIR}/${bindir}/python3-config
> }
>
> Note that the sysroot code plays with hardlinks for efficiency, I
> appreciate one file doesn't really matter though.
>
> I was hoping we could have just added to SYSROOT_DIRS but that does
> only handle dirs, not files.
>
> Cheers,
>
> Richard
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#173003): https://lists.openembedded.org/g/openembedded-core/message/173003
> Mute This Topic: https://lists.openembedded.org/mt/94867622/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Alexander Kanavin Nov. 9, 2022, 12:56 p.m. UTC | #3
Yes, I got these to fail:
  /srv/work/alex/meta-openembedded/meta-python/recipes-devtools/python/python3-ipy_1.01.bb:do_install
  /srv/work/alex/meta-openembedded/meta-python/recipes-extended/python-meh/python3-meh_0.50.1.bb:do_install
  /srv/work/alex/meta-openembedded/meta-networking/recipes-connectivity/ufw/ufw_0.36.1.bb:do_install
  virtual:native:/srv/work/alex/meta-openembedded/meta-networking/recipes-protocols/frr/frr_8.3.1.bb:do_configure
  /srv/work/alex/meta-openembedded/meta-oe/dynamic-layers/meta-python/recipes-connectivity/lirc/lirc_0.10.2.bb:do_compile
  /srv/work/alex/meta-openembedded/meta-gnome/recipes-gimp/babl/babl_0.1.96.bb:do_compile
  /srv/work/alex/meta-openembedded/meta-oe/recipes-devtools/unattended-upgrades/unattended-upgrades_2.9.1.bb:do_install
  /srv/work/alex/meta-openembedded/meta-xfce/recipes-apps/menulibre/menulibre_2.2.3.bb:do_install
  /srv/work/alex/meta-openembedded/meta-gnome/recipes-gnome/gedit/gedit_42.2.bb:do_compile
  /srv/work/alex/meta-openembedded/meta-gnome/recipes-gnome/gnome-online-accounts/gnome-online-accounts_3.44.0.bb:do_configure

So it's not as painless as I expected, I'll look into what's wrong with these.

Alex

On Wed, 9 Nov 2022 at 04:47, Khem Raj <raj.khem@gmail.com> wrote:
>
> I am seeing a bunch of failures perhaps related but not sure
>
> https://errors.yoctoproject.org/Errors/Build/154610/
>
> On Tue, Nov 8, 2022 at 2:59 PM Richard Purdie
> <richard.purdie@linuxfoundation.org> wrote:
> >
> > On Mon, 2022-11-07 at 15:55 +0100, Alexander Kanavin wrote:
> > >
> > > +SYSROOT_PREPROCESS_FUNCS:append:class-target = " provide_target_config_script"
> > > +SYSROOT_PREPROCESS_FUNCS:append:class-nativesdk = " provide_target_config_script"
> > > +
> > > +provide_target_config_script() {
> > > +        install -d ${SYSROOT_DESTDIR}${bindir}/
> > > +        install ${D}/${bindir}/python3-config ${SYSROOT_DESTDIR}${bindir}/
> > > +        install ${D}/${bindir}/python${PYTHON_MAJMIN}-config ${SYSROOT_DESTDIR}${bindir}/
> > > +}
> > > +
> > > +
> > >  SSTATE_SCAN_FILES += "Makefile _sysconfigdata.py"
> > >  SSTATE_HASHEQUIV_FILEMAP = " \
> > >      populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${TMPDIR} \
> >
> > This made me wonder if we shouldn't have a better way of handling this.
> > I was wondering if we should have a sysroot_stage_file function (like
> > sysroot_stage_dir) and then we could do something like:
> >
> > sysroot_stage_all:append() {
> >         sysroot_stage_file ${D}/${bindir}/python3-config ${SYSROOT_DESTDIR}/${bindir}/python3-config
> > }
> >
> > Note that the sysroot code plays with hardlinks for efficiency, I
> > appreciate one file doesn't really matter though.
> >
> > I was hoping we could have just added to SYSROOT_DIRS but that does
> > only handle dirs, not files.
> >
> > Cheers,
> >
> > Richard
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#173003): https://lists.openembedded.org/g/openembedded-core/message/173003
> > Mute This Topic: https://lists.openembedded.org/mt/94867622/1997914
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
Alexander Kanavin Nov. 9, 2022, 1:05 p.m. UTC | #4
On Tue, 8 Nov 2022 at 23:59, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
> This made me wonder if we shouldn't have a better way of handling this.
> I was wondering if we should have a sysroot_stage_file function (like
> sysroot_stage_dir) and then we could do something like:
>
> sysroot_stage_all:append() {
>         sysroot_stage_file ${D}/${bindir}/python3-config ${SYSROOT_DESTDIR}/${bindir}/python3-config
> }
>
> Note that the sysroot code plays with hardlinks for efficiency, I
> appreciate one file doesn't really matter though.
>
> I was hoping we could have just added to SYSROOT_DIRS but that does
> only handle dirs, not files.

Wouldn't sysroot_stage_file be just syntactic sugar though? I'm fine
with just running 'install' directly in sysroot_stage_all:append(),
especially as it's more self-explanatory that way.

Alex
Alexander Kanavin Nov. 9, 2022, 8:36 p.m. UTC | #5
I've sent a couple fixes to meta-oe, and v2 of the patchset here.
Particularly, "python3: correctly adjust include paths in
sysconfigdata" is important, as somehow setuptools update made it to
master and ppl will start seeing these:
https://autobuilder.yoctoproject.org/typhoon/#/builders/20/builds/6514/steps/11/logs/stdio

Alex

On Wed, 9 Nov 2022 at 13:56, Alexander Kanavin <alex.kanavin@gmail.com> wrote:
>
> Yes, I got these to fail:
>   /srv/work/alex/meta-openembedded/meta-python/recipes-devtools/python/python3-ipy_1.01.bb:do_install
>   /srv/work/alex/meta-openembedded/meta-python/recipes-extended/python-meh/python3-meh_0.50.1.bb:do_install
>   /srv/work/alex/meta-openembedded/meta-networking/recipes-connectivity/ufw/ufw_0.36.1.bb:do_install
>   virtual:native:/srv/work/alex/meta-openembedded/meta-networking/recipes-protocols/frr/frr_8.3.1.bb:do_configure
>   /srv/work/alex/meta-openembedded/meta-oe/dynamic-layers/meta-python/recipes-connectivity/lirc/lirc_0.10.2.bb:do_compile
>   /srv/work/alex/meta-openembedded/meta-gnome/recipes-gimp/babl/babl_0.1.96.bb:do_compile
>   /srv/work/alex/meta-openembedded/meta-oe/recipes-devtools/unattended-upgrades/unattended-upgrades_2.9.1.bb:do_install
>   /srv/work/alex/meta-openembedded/meta-xfce/recipes-apps/menulibre/menulibre_2.2.3.bb:do_install
>   /srv/work/alex/meta-openembedded/meta-gnome/recipes-gnome/gedit/gedit_42.2.bb:do_compile
>   /srv/work/alex/meta-openembedded/meta-gnome/recipes-gnome/gnome-online-accounts/gnome-online-accounts_3.44.0.bb:do_configure
>
> So it's not as painless as I expected, I'll look into what's wrong with these.
>
> Alex
>
> On Wed, 9 Nov 2022 at 04:47, Khem Raj <raj.khem@gmail.com> wrote:
> >
> > I am seeing a bunch of failures perhaps related but not sure
> >
> > https://errors.yoctoproject.org/Errors/Build/154610/
> >
> > On Tue, Nov 8, 2022 at 2:59 PM Richard Purdie
> > <richard.purdie@linuxfoundation.org> wrote:
> > >
> > > On Mon, 2022-11-07 at 15:55 +0100, Alexander Kanavin wrote:
> > > >
> > > > +SYSROOT_PREPROCESS_FUNCS:append:class-target = " provide_target_config_script"
> > > > +SYSROOT_PREPROCESS_FUNCS:append:class-nativesdk = " provide_target_config_script"
> > > > +
> > > > +provide_target_config_script() {
> > > > +        install -d ${SYSROOT_DESTDIR}${bindir}/
> > > > +        install ${D}/${bindir}/python3-config ${SYSROOT_DESTDIR}${bindir}/
> > > > +        install ${D}/${bindir}/python${PYTHON_MAJMIN}-config ${SYSROOT_DESTDIR}${bindir}/
> > > > +}
> > > > +
> > > > +
> > > >  SSTATE_SCAN_FILES += "Makefile _sysconfigdata.py"
> > > >  SSTATE_HASHEQUIV_FILEMAP = " \
> > > >      populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${TMPDIR} \
> > >
> > > This made me wonder if we shouldn't have a better way of handling this.
> > > I was wondering if we should have a sysroot_stage_file function (like
> > > sysroot_stage_dir) and then we could do something like:
> > >
> > > sysroot_stage_all:append() {
> > >         sysroot_stage_file ${D}/${bindir}/python3-config ${SYSROOT_DESTDIR}/${bindir}/python3-config
> > > }
> > >
> > > Note that the sysroot code plays with hardlinks for efficiency, I
> > > appreciate one file doesn't really matter though.
> > >
> > > I was hoping we could have just added to SYSROOT_DIRS but that does
> > > only handle dirs, not files.
> > >
> > > Cheers,
> > >
> > > Richard
> > >
> > > -=-=-=-=-=-=-=-=-=-=-=-
> > > Links: You receive all messages sent to this group.
> > > View/Reply Online (#173003): https://lists.openembedded.org/g/openembedded-core/message/173003
> > > Mute This Topic: https://lists.openembedded.org/mt/94867622/1997914
> > > Group Owner: openembedded-core+owner@lists.openembedded.org
> > > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> > > -=-=-=-=-=-=-=-=-=-=-=-
> > >
diff mbox series

Patch

diff --git a/meta/classes-recipe/python3targetconfig.bbclass b/meta/classes-recipe/python3targetconfig.bbclass
index 3f89e5e09e..e5187bb459 100644
--- a/meta/classes-recipe/python3targetconfig.bbclass
+++ b/meta/classes-recipe/python3targetconfig.bbclass
@@ -10,26 +10,31 @@  EXTRA_PYTHON_DEPENDS ?= ""
 EXTRA_PYTHON_DEPENDS:class-target = "python3"
 DEPENDS:append = " ${EXTRA_PYTHON_DEPENDS}"
 
-do_configure:prepend:class-target() {
+setup_target_config() {
         export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
+        export PATH=${STAGING_BINDIR}:$PATH
+}
+
+do_configure:prepend:class-target() {
+        setup_target_config
 }
 
 do_compile:prepend:class-target() {
-        export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
+        setup_target_config
 }
 
 do_install:prepend:class-target() {
-        export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
+        setup_target_config
 }
 
 do_configure:prepend:class-nativesdk() {
-        export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
+        setup_target_config
 }
 
 do_compile:prepend:class-nativesdk() {
-        export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
+        setup_target_config
 }
 
 do_install:prepend:class-nativesdk() {
-        export _PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata"
+        setup_target_config
 }
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 @@ 
-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
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 @@ 
-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
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 @@ 
-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))
diff --git a/meta/recipes-devtools/python/python3_3.11.0.bb b/meta/recipes-devtools/python/python3_3.11.0.bb
index 92a1f69320..7bfe7b2713 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 \
            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 \
@@ -172,6 +170,9 @@  do_install:append:class-native() {
         
         # disable the lookup in user's site-packages globally
         sed -i 's#ENABLE_USER_SITE = None#ENABLE_USER_SITE = False#' ${D}${libdir}/python${PYTHON_MAJMIN}/site.py
+
+        # python3-config needs to be in /usr/bin and not in a subdir of it to work properly
+        mv ${D}/${bindir}/${PN}/python*config ${D}/${bindir}/
 }
 
 do_install:append() {
@@ -220,6 +221,16 @@  do_install:append:class-nativesdk () {
     create_wrapper ${D}${bindir}/python${PYTHON_MAJMIN} TERMINFO_DIRS='${sysconfdir}/terminfo:/etc/terminfo:/usr/share/terminfo:/usr/share/misc/terminfo:/lib/terminfo' PYTHONNOUSERSITE='1'
 }
 
+SYSROOT_PREPROCESS_FUNCS:append:class-target = " provide_target_config_script"
+SYSROOT_PREPROCESS_FUNCS:append:class-nativesdk = " provide_target_config_script"
+
+provide_target_config_script() {
+        install -d ${SYSROOT_DESTDIR}${bindir}/
+        install ${D}/${bindir}/python3-config ${SYSROOT_DESTDIR}${bindir}/
+        install ${D}/${bindir}/python${PYTHON_MAJMIN}-config ${SYSROOT_DESTDIR}${bindir}/
+}
+
+
 SSTATE_SCAN_FILES += "Makefile _sysconfigdata.py"
 SSTATE_HASHEQUIV_FILEMAP = " \
     populate_sysroot:*/lib*/python3*/_sysconfigdata*.py:${TMPDIR} \