Skip to contentSkip to conversation

deprecation of distutils

RFC PATCH Superseded Tim Orling 2 participants 29 messages Nov 26, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Tim Orling

author
#0 lore raw

cover deprecation of distutils

distutils is deprecated in Python 3.10 and will be removed in Python 3.12 (~October 2023).

This series inserts a deprecation warning into the distutils*.bbclasses and drops or replaces distutils usage wherever possible.

Instead of distutils3-base, we introduce setuptools3-base, which also incorporates distutils-common-base.

Remaining usage is in:
* lib/recipetool/create_buildsys_python.py until we are ready to factor it out (and add pyproject.toml and setup.cfg handling)
* oeqa selftests which are testing distutils3 functionality
* glib-2.0: upstream is still using distutils.version.LooseVersion
* gpgme: Still checks for distutils in m4/ax_python_devel.m4
* python3-numpy: upstream still has a distutils/ module
* python3-setuptools has a vendored _distutils

I might have missed something else.

No attempt has been made to look at layers outside of oe-core.

The intent is to let this percolate for a few weeks and then drop distutils*.bbclasses (and move them to meta-python, but with the warnings).

[YOCTO #14610]

The following changes since commit 6fca075a8d87d033359f81d476c8506df66ad53d:

gcc: Drop no longer needed patch (2021-11-25 21:53:44 +0000)

are available in the Git repository at:

git://push.openembedded.org/openembedded-core-contrib timo/core-deprecate-distutils_14610

Tim Orling (26):
classes/distutils-*: add warning of deprecation
setuptools: refactor for no distutils bbclasses
python3-cython: DISTUTILS_* -> SETUPTOOLS_*
dnf: inherit setuptools3-base instead of distutils
libdnf: inherit setuptoools3-base not distutils
python3-dbus: inherit setuptools3-base not distuils
gpgme: inherit setuptools-base not distutils
python3-pip: inherit setuptools3 not distutils3
systemtap: use setuptools-base not distutils
libcomps: inherit setuptools3-base not distutils
createrepo-c: inherit setuptools3-base not distutils
librepo: inherit setuptools3-base not distutils
btrfs-tools: use setuptools3-base not distutils scripts/buildhistory-diff: drop use of distutils
python3-pygobject: setuptools instead of distutils
bind: inherit setuptools3-base instead of distutils
python3-setuptools: do not depend on distutils sanity.bbclass: drop usage of distutils gstreamer1.0-python: inherit setuptools3-base recipetool/create_buildsys_python.py: less distutils waf.bbclass: drop usage of distutils
dnf: drop python3-disutils dependency
python3: refactor python-config patch lib/oe/terminal.py: use bb.version.LooseVersion python3native.bbclass: distutils -> sysconfig rootfs_rpm.bbclass: distutils -> sysconfig module

 meta/classes/distutils-common-base.bbclass    |  3 +
 meta/classes/distutils3-base.bbclass          |  3 +
 meta/classes/distutils3.bbclass               |  4 ++
 meta/classes/python3native.bbclass            |  2 +-
 meta/classes/rootfs_rpm.bbclass               |  2 +-
 meta/classes/sanity.bbclass                   | 16 ++---
 meta/classes/setuptools3-base.bbclass         | 31 +++++++++
 meta/classes/setuptools3.bbclass              | 67 +++++++++++++++++-
 meta/classes/waf.bbclass                      |  2 +-
 meta/lib/oe/terminal.py                       |  2 +-
 .../recipes-connectivity/bind/bind_9.16.23.bb |  2 +-
 .../btrfs-tools/btrfs-tools_5.15.bb           |  2 +-
 .../createrepo-c/createrepo-c_0.17.7.bb       |  2 +-
 meta/recipes-devtools/dnf/dnf_4.10.0.bb       |  3 +-
 .../libcomps/libcomps_0.1.18.bb               |  2 +-
 meta/recipes-devtools/libdnf/libdnf_0.65.0.bb |  2 +-
 .../librepo/librepo_1.14.2.bb                 |  2 +-
 .../python/python3-cython_0.29.24.bb          |  2 +-
 .../python/python3-dbus_1.2.18.bb             |  2 +-
 .../python/python3-pip_21.3.1.bb              |  2 +-
 .../python/python3-pygobject_3.42.0.bb        |  2 +-
 .../python/python3-setuptools_59.2.0.bb       |  1 -
 ...n-implement-legacy-disutils-behavior.patch | 68 +++++++++++++++++++
 .../python/python3/python-config.patch        | 55 ---------------
 .../recipes-devtools/python/python3_3.10.0.bb |  2 +-
 .../recipes-kernel/systemtap/systemtap_git.bb |  2 +-
 .../gstreamer/gstreamer1.0-python_1.18.5.bb   |  2 +-
 meta/recipes-support/gpgme/gpgme_1.16.0.bb    |  2 +-
 scripts/buildhistory-diff                     |  5 --
 .../lib/recipetool/create_buildsys_python.py  |  4 +-
 30 files changed, 204 insertions(+), 92 deletions(-)
 create mode 100644 meta/classes/setuptools3-base.bbclass
 create mode 100644 meta/recipes-devtools/python/python3/0001-python-config.in-implement-legacy-disutils-behavior.patch
 delete mode 100644 meta/recipes-devtools/python/python3/python-config.patch
Signature · 1 line
2.30.2
author
#1 lore raw

RFC PATCH 1/26 classes/distutils-*: add warning of deprecation

distutils has been deprecated in Python 3.10 and will be removed in Python 3.12 (predicted release date October 2023).

Add a warning now that recommends using the roughly equivalent setuptools-* classes.

[YOCTO #14610]

---
 meta/classes/distutils-common-base.bbclass | 3 +++
 meta/classes/distutils3-base.bbclass       | 3 +++
 meta/classes/distutils3.bbclass            | 4 ++++
 3 files changed, 10 insertions(+)
meta/classes/distutils-common-base.bbclass +3 -0
index bc994f78de3..59c750a3cf7 100644
@@ -23,3 +23,6 @@ FILES:${PN}-dev += "\
   ${libdir}/pkgconfig \
   ${PYTHON_SITEPACKAGES_DIR}/*.la \
 "
+python __anonymous() {
+    bb.warn("distutils-common-base.bbclass is deprecated, please use setuptools3-base.bbclass instead")
+}
meta/classes/distutils3-base.bbclass +3 -0
index d41873e4869..850c535bb17 100644
@@ -4,3 +4,6 @@ RDEPENDS:${PN} += "${@['', '${PYTHON_PN}-core']['${CLASSOVERRIDE}' == 'class-tar
 
 inherit distutils-common-base python3native python3targetconfig
 
+python __anonymous() {
+    bb.warn("distutils3-base.bbclass is deprecated, please use setuptools3-base.bbclass instead")
+
meta/classes/distutils3.bbclass +4 -0
index be645d37bd0..a6d8e8763f3 100644
@@ -14,6 +14,10 @@ DISTUTILS_PYTHON:class-native = "nativepython3"
 
 DISTUTILS_SETUP_PATH ?= "${S}"
 
+python __anonymous() {
+    bb.warn("distutils3.bbclass is deprecated, please use setuptools3.bbclass instead")
+}
+
 distutils3_do_configure() {
     :
 }
Signature · 1 line
2.30.2
author
#2 lore raw

RFC PATCH 2/26 setuptools: refactor for no distutils bbclasses

In reply to Tim Orling
---
 meta/classes/setuptools3-base.bbclass | 31 +++++++++++++
 meta/classes/setuptools3.bbclass      | 67 ++++++++++++++++++++++++++-
 2 files changed, 97 insertions(+), 1 deletion(-)
 create mode 100644 meta/classes/setuptools3-base.bbclass
meta/classes/setuptools3-base.bbclass new file +31 -0
new file mode 100644
index 00000000000..5098ae9d64e
@@ -0,0 +1,31 @@
+DEPENDS:append:class-target = " ${PYTHON_PN}-native ${PYTHON_PN}"
+DEPENDS:append:class-nativesdk = " ${PYTHON_PN}-native ${PYTHON_PN}"
+RDEPENDS:${PN} += "${@['', '${PYTHON_PN}-core']['${CLASSOVERRIDE}' == 'class-target']}"
+
+export STAGING_INCDIR
+export STAGING_LIBDIR
+
+# LDSHARED is the ld *command* used to create shared library
+export LDSHARED  = "${CCLD} -shared"
+# LDXXSHARED is the ld *command* used to create shared library of C++
+# objects
+export LDCXXSHARED  = "${CXX} -shared"
+# CCSHARED are the C *flags* used to create objects to go into a shared
+# library (module)
+export CCSHARED  = "-fPIC -DPIC"
+# LINKFORSHARED are the flags passed to the $(CC) command that links
+# the python executable
+export LINKFORSHARED = "${SECURITY_CFLAGS} -Xlinker -export-dynamic"
+
+FILES:${PN} += "${libdir}/* ${libdir}/${PYTHON_DIR}/*"
+
+FILES:${PN}-staticdev += "\
+  ${PYTHON_SITEPACKAGES_DIR}/*.a \
+"
+FILES:${PN}-dev += "\
+  ${datadir}/pkgconfig \
+  ${libdir}/pkgconfig \
+  ${PYTHON_SITEPACKAGES_DIR}/*.la \
+"
+inherit python3native python3targetconfig
+
meta/classes/setuptools3.bbclass +66 -1

70 lines not on this page · raw message

Signature · 1 line
2.30.2
#3 lore raw

Re: [OE-core] [RFC PATCH 02/26] setuptools: refactor for no distutils bbclasses

Quoted 49 lines · Tim Orling
---
  meta/classes/setuptools3-base.bbclass | 31 +++++++++++++
  meta/classes/setuptools3.bbclass      | 67 ++++++++++++++++++++++++++-
  2 files changed, 97 insertions(+), 1 deletion(-)

create mode 100644 meta/classes/setuptools3-base.bbclass

meta/classes/setuptools3-base.bbclass new file +31 -0
new file mode 100644
index 00000000000..5098ae9d64e
@@ -0,0 +1,31 @@
+DEPENDS:append:class-target = " ${PYTHON_PN}-native ${PYTHON_PN}"
+DEPENDS:append:class-nativesdk = " ${PYTHON_PN}-native ${PYTHON_PN}"
+RDEPENDS:${PN} += "${@['', '${PYTHON_PN}-core']['${CLASSOVERRIDE}' == 'class-target']}"
+
+export STAGING_INCDIR
+export STAGING_LIBDIR
+
+# LDSHARED is the ld *command* used to create shared library
+export LDSHARED  = "${CCLD} -shared"
+# LDXXSHARED is the ld *command* used to create shared library of C++
+# objects
+export LDCXXSHARED  = "${CXX} -shared"
+# CCSHARED are the C *flags* used to create objects to go into a shared
+# library (module)
+export CCSHARED  = "-fPIC -DPIC"
+# LINKFORSHARED are the flags passed to the $(CC) command that links
+# the python executable
+export LINKFORSHARED = "${SECURITY_CFLAGS} -Xlinker -export-dynamic"
+
+FILES:${PN} += "${libdir}/* ${libdir}/${PYTHON_DIR}/*"
+
+FILES:${PN}-staticdev += "\
+  ${PYTHON_SITEPACKAGES_DIR}/*.a \
+"
+FILES:${PN}-dev += "\
+  ${datadir}/pkgconfig \
+  ${libdir}/pkgconfig \
+  ${PYTHON_SITEPACKAGES_DIR}/*.la \
+"
+inherit python3native python3targetconfig
+
meta/classes/setuptools3.bbclass +0 -0
index 8ca66ee708e..4b8eca3f96e 100644

meta/classes/setuptools3.bbclass line 4

Quoted 5 lines
meta/classes/setuptools3.bbclass +3 -1
@@ -1,4 +1,69 @@
-inherit distutils3
+inherit setuptools3-base
 
+B = "${WORKDIR}/build"
+distutils_do_configure[cleandirs] = "${B}"

I hope this will be removed in a later patch, as the function name doesn't match the rest of the class code function naming. Or this here deserves a in code explantion

Quoted 5 lines
meta/classes/setuptools3.bbclass +5 -0
+
+SETUPTOOLS_BUILD_ARGS ?= ""
+SETUPTOOLS_INSTALL_ARGS ?= "--root=${D} \
+    --prefix=${prefix} \
+    --install-lib=${PYTHON_SITEPACKAGES_DIR} \

meta/classes/setuptools3.bbclass line 19

Quoted 10 lines
meta/classes/setuptools3.bbclass +10 -0
+    --install-data=${datadir}"
+
+SETUPTOOLS_PYTHON = "python3"
+SETUPTOOLS_PYTHON:class-native = "nativepython3"
+
+SETUPTOOLS_SETUP_PATH ?= "${S}"
+
+setuptools3_do_configure() {
+    :
+}

Why do we need to export an empty function?
Wouldn't it make sense to use noexec here?

meta/classes/setuptools3.bbclass line 30

Quoted 11 lines
meta/classes/setuptools3.bbclass +11 -0
+
+setuptools3_do_compile() {
+        cd ${SETUPTOOLS_SETUP_PATH}
+        NO_FETCH_BUILD=1 \
+        STAGING_INCDIR=${STAGING_INCDIR} \
+        STAGING_LIBDIR=${STAGING_LIBDIR} \
+        ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py \
+        build --build-base=${B} ${SETUPTOOLS_BUILD_ARGS} || \
+        bbfatal_log "'${PYTHON_PN} setup.py build ${SETUPTOOLS_BUILD_ARGS}' execution failed."
+}
+setuptools3_do_compile[vardepsexclude] = "MACHINE"

Please append or += here otherwise manipulation done to this function vardepexclude done *before* the inherit in the recipe will be lost, without people noticing that easily

Quoted 23 lines
meta/classes/setuptools3.bbclass +23 -0
+
+setuptools3_do_install() {
+        cd ${SETUPTOOLS_SETUP_PATH}
+        install -d ${D}${PYTHON_SITEPACKAGES_DIR}
+        STAGING_INCDIR=${STAGING_INCDIR} \
+        STAGING_LIBDIR=${STAGING_LIBDIR} \
+        PYTHONPATH=${D}${PYTHON_SITEPACKAGES_DIR} \
+        ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN} setup.py \
+        build --build-base=${B} install --skip-build ${SETUPTOOLS_INSTALL_ARGS} || \
+        bbfatal_log "'${PYTHON_PN} setup.py install ${SETUPTOOLS_INSTALL_ARGS}' execution failed."
+
+        # support filenames with *spaces*
+        find ${D} -name "*.py" -exec grep -q ${D} {} \; \
+                               -exec sed -i -e s:${D}::g {} \;
+
+        for i in ${D}${bindir}/* ${D}${sbindir}/*; do
+            if [ -f "$i" ]; then
+                sed -i -e s:${PYTHON}:${USRBINPATH}/env\ ${SETUPTOOLS_PYTHON}:g $i
+                sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
+            fi
+        done
+
+        rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/easy-install.pth

meta/classes/setuptools3.bbclass line 63

Quoted 10 lines
meta/classes/setuptools3.bbclass +10 -0
+
+        #
+        # FIXME: Bandaid against wrong datadir computation
+        #
+        if [ -e ${D}${datadir}/share ]; then
+            mv -f ${D}${datadir}/share/* ${D}${datadir}/
+            rmdir ${D}${datadir}/share
+        fi
+}
+setuptools3_do_install[vardepsexclude] = "MACHINE"

Same here about the vardepexclude

Quoted 17 lines
meta/classes/setuptools3.bbclass +4 -1
+
+EXPORT_FUNCTIONS do_configure do_compile do_install
+
+export LDSHARED="${CCLD} -shared"
  DEPENDS += "python3-setuptools-native"
 
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#158798): https://lists.openembedded.org/g/openembedded-core/message/158798
Mute This Topic: https://lists.openembedded.org/mt/87313857/3647476
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

author
#4 lore raw

Re: [OE-core] [RFC PATCH 02/26] setuptools: refactor for no distutils bbclasses

Quoted 58 lines · Konrad Weihmann

Review

Quoted 8 lines · Tim Orling
---
  meta/classes/setuptools3-base.bbclass | 31 +++++++++++++
  meta/classes/setuptools3.bbclass      | 67 ++++++++++++++++++++++++++-
  2 files changed, 97 insertions(+), 1 deletion(-)

create mode 100644 meta/classes/setuptools3-base.bbclass

(quoted diff) +0 -0

b/meta/classes/setuptools3-base.bbclass

meta/classes/setuptools3-base.bbclass line 3

Quoted 8 lines

new file mode 100644
index 00000000000..5098ae9d64e

meta/classes/setuptools3-base.bbclass new file +3 -0
@@ -0,0 +1,31 @@
+DEPENDS:append:class-target = " ${PYTHON_PN}-native ${PYTHON_PN}"
+DEPENDS:append:class-nativesdk = " ${PYTHON_PN}-native ${PYTHON_PN}"
+RDEPENDS:${PN} += "${@['', '${PYTHON_PN}-core']['${CLASSOVERRIDE}' ==

'class-target']}"

Review

Quoted 29 lines
meta/classes/setuptools3-base.bbclass new file +28 -0
+
+export STAGING_INCDIR
+export STAGING_LIBDIR
+
+# LDSHARED is the ld *command* used to create shared library
+export LDSHARED  = "${CCLD} -shared"
+# LDXXSHARED is the ld *command* used to create shared library of C++
+# objects
+export LDCXXSHARED  = "${CXX} -shared"
+# CCSHARED are the C *flags* used to create objects to go into a shared
+# library (module)
+export CCSHARED  = "-fPIC -DPIC"
+# LINKFORSHARED are the flags passed to the $(CC) command that links
+# the python executable
+export LINKFORSHARED = "${SECURITY_CFLAGS} -Xlinker -export-dynamic"
+
+FILES:${PN} += "${libdir}/* ${libdir}/${PYTHON_DIR}/*"
+
+FILES:${PN}-staticdev += "\
+  ${PYTHON_SITEPACKAGES_DIR}/*.a \
+"
+FILES:${PN}-dev += "\
+  ${datadir}/pkgconfig \
+  ${libdir}/pkgconfig \
+  ${PYTHON_SITEPACKAGES_DIR}/*.la \
+"
+inherit python3native python3targetconfig
+
(quoted diff) +0 -0

b/meta/classes/setuptools3.bbclass

Quoted 7 lines

index 8ca66ee708e..4b8eca3f96e 100644

meta/classes/setuptools3.bbclass +1 -1
@@ -1,4 +1,69 @@
-inherit distutils3
+inherit setuptools3-base
 
Quoted 8 lines

meta/classes/setuptools3.bbclass line 4

Quoted 2 lines
meta/classes/setuptools3.bbclass +2 -0
+B = "${WORKDIR}/build"
+distutils_do_configure[cleandirs] = "${B}"

I hope this will be removed in a later patch, as the function name doesn't match the rest of the class code function naming. Or this here deserves a in code explantion

This was a copy-paste oversight and needs to be changed in a v2.

I believe I was trying to contemplate if it was still needed and forgot to loop back.
https://git.yoctoproject.org/poky/tree/meta/classes/distutils3.bbclass#n4

Quoted 19 lines

+

Quoted 4 lines
meta/classes/setuptools3.bbclass +4 -0
+SETUPTOOLS_BUILD_ARGS ?= ""
+SETUPTOOLS_INSTALL_ARGS ?= "--root=${D} \
+    --prefix=${prefix} \
+    --install-lib=${PYTHON_SITEPACKAGES_DIR} \

meta/classes/setuptools3.bbclass line 19

Quoted 10 lines
meta/classes/setuptools3.bbclass +10 -0
+    --install-data=${datadir}"
+
+SETUPTOOLS_PYTHON = "python3"
+SETUPTOOLS_PYTHON:class-native = "nativepython3"
+
+SETUPTOOLS_SETUP_PATH ?= "${S}"
+
+setuptools3_do_configure() {
+    :
+}

Why do we need to export an empty function?
Wouldn't it make sense to use noexec here?

Quoted 1 line

This is what was in the original distutils3.bbclass

https://git.yoctoproject.org/poky/tree/meta/classes/distutils3.bbclass#n18
The colon (:) makes it a no-op (not empty). I believe this is our version of defining an "interface" that can be implemented by subsequent recipes inheriting the class.

Quoted 11 lines

+

meta/classes/setuptools3.bbclass

Quoted 6 lines
meta/classes/setuptools3.bbclass +6 -0
+setuptools3_do_compile() {
+        cd ${SETUPTOOLS_SETUP_PATH}
+        NO_FETCH_BUILD=1 \
+        STAGING_INCDIR=${STAGING_INCDIR} \
+        STAGING_LIBDIR=${STAGING_LIBDIR} \
+        ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN}

setup.py \

meta/classes/setuptools3.bbclass line 26

Quoted 2 lines
meta/classes/setuptools3.bbclass +2 -0
+        build --build-base=${B} ${SETUPTOOLS_BUILD_ARGS} || \
+        bbfatal_log "'${PYTHON_PN} setup.py build

${SETUPTOOLS_BUILD_ARGS}' execution failed."

Quoted 8 lines

meta/classes/setuptools3.bbclass line 28

Quoted 2 lines
meta/classes/setuptools3.bbclass +2 -0
+}
+setuptools3_do_compile[vardepsexclude] = "MACHINE"

Please append or += here otherwise manipulation done to this function vardepexclude done *before* the inherit in the recipe will be lost, without people noticing that easily

This is directly from the original distutils3.bbclass

https://git.yoctoproject.org/poky/tree/meta/classes/distutils3.bbclass#n30

Quoted 40 lines

+

meta/classes/setuptools3.bbclass

Quoted 7 lines
meta/classes/setuptools3.bbclass +7 -0
+setuptools3_do_install() {
+        cd ${SETUPTOOLS_SETUP_PATH}
+        install -d ${D}${PYTHON_SITEPACKAGES_DIR}
+        STAGING_INCDIR=${STAGING_INCDIR} \
+        STAGING_LIBDIR=${STAGING_LIBDIR} \
+        PYTHONPATH=${D}${PYTHON_SITEPACKAGES_DIR} \
+        ${STAGING_BINDIR_NATIVE}/${PYTHON_PN}-native/${PYTHON_PN}

setup.py \

meta/classes/setuptools3.bbclass line 36

Quoted 1 line
meta/classes/setuptools3.bbclass +1 -0
+        build --build-base=${B} install --skip-build

${SETUPTOOLS_INSTALL_ARGS} || \

meta/classes/setuptools3.bbclass line 37

Quoted 1 line
meta/classes/setuptools3.bbclass +1 -0
+        bbfatal_log "'${PYTHON_PN} setup.py install

${SETUPTOOLS_INSTALL_ARGS}' execution failed."

meta/classes/setuptools3.bbclass

Quoted 8 lines
meta/classes/setuptools3.bbclass +8 -0
+
+        # support filenames with *spaces*
+        find ${D} -name "*.py" -exec grep -q ${D} {} \; \
+                               -exec sed -i -e s:${D}::g {} \;
+
+        for i in ${D}${bindir}/* ${D}${sbindir}/*; do
+            if [ -f "$i" ]; then
+                sed -i -e s:${PYTHON}:${USRBINPATH}/env\

${SETUPTOOLS_PYTHON}:g $i

Quoted 5 lines
meta/classes/setuptools3.bbclass +5 -0
+                sed -i -e s:${STAGING_BINDIR_NATIVE}:${bindir}:g $i
+            fi
+        done
+
+        rm -f ${D}${PYTHON_SITEPACKAGES_DIR}/easy-install.pth

meta/classes/setuptools3.bbclass line 63

Quoted 10 lines
meta/classes/setuptools3.bbclass +10 -0
+
+        #
+        # FIXME: Bandaid against wrong datadir computation
+        #
+        if [ -e ${D}${datadir}/share ]; then
+            mv -f ${D}${datadir}/share/* ${D}${datadir}/
+            rmdir ${D}${datadir}/share
+        fi
+}
+setuptools3_do_install[vardepsexclude] = "MACHINE"

Same here about the vardepexclude

Quoted 1 line

Again, this is directly from the distutil3.bbclass

https://git.yoctoproject.org/poky/tree/meta/classes/distutils3.bbclass#n63

Quoted 20 lines

+

Quoted 11 lines
meta/classes/setuptools3.bbclass +3 -1
+EXPORT_FUNCTIONS do_configure do_compile do_install
+
+export LDSHARED="${CCLD} -shared"
  DEPENDS += "python3-setuptools-native"
 
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group. View/Reply Online (#158798):

https://lists.openembedded.org/g/openembedded-core/message/158798

Quoted 3 lines

Mute This Topic: https://lists.openembedded.org/mt/87313857/3647476
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [

[email protected]]

Quoted 2 lines

-=-=-=-=-=-=-=-=-=-=-=-

author
#5 lore raw

RFC PATCH 3/26 python3-cython: DISTUTILS_* -> SETUPTOOLS_*

In reply to Tim Orling

Refactor to new SETUPTOOLS_* variables

[YOCTO #14610]

---
 meta/recipes-devtools/python/python3-cython_0.29.24.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/python/python3-cython_0.29.24.bb +1 -1
index b1d21bd15c0..26333cb2718 100644
@@ -8,7 +8,7 @@ RDEPENDS:${PN} += "\
 # running build_ext a second time during install fails, because Python
 # would then attempt to import cythonized modules built for the target
 # architecture.
-DISTUTILS_INSTALL_ARGS += "--skip-build"
+SETUPTOOLS_INSTALL_ARGS += "--skip-build"
 
 do_install:append() {
     # rename scripts that would conflict with the Python 2 build of Cython
Signature · 1 line
2.30.2
author
#6 lore raw

RFC PATCH 4/26 dnf: inherit setuptools3-base instead of distutils

In reply to Tim Orling

[YOCTO #14610]

---
 meta/recipes-devtools/dnf/dnf_4.10.0.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/dnf/dnf_4.10.0.bb +1 -1
index cef2c03e4e2..6ff2a6b1e6f 100644
@@ -23,7 +23,7 @@ UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>\d+(\.\d+)+)"
 
 S = "${WORKDIR}/git"
 
-inherit cmake gettext bash-completion distutils3-base systemd
+inherit cmake gettext bash-completion setuptools3-base systemd
 
 DEPENDS += "libdnf librepo libcomps python3-iniparse"
 
Signature · 1 line
2.30.2
author
#7 lore raw

RFC PATCH 5/26 libdnf: inherit setuptoools3-base not distutils

In reply to Tim Orling

[YOCTO #14610]

---
 meta/recipes-devtools/libdnf/libdnf_0.65.0.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/libdnf/libdnf_0.65.0.bb +1 -1
index fbda7769c07..81da04c9ca1 100644
@@ -22,7 +22,7 @@ S = "${WORKDIR}/git"
 
 DEPENDS = "glib-2.0 libsolv libcheck librepo rpm gtk-doc libmodulemd json-c swig-native"
 
-inherit gtk-doc gobject-introspection cmake pkgconfig distutils3-base
+inherit gtk-doc gobject-introspection cmake pkgconfig setuptools3-base
 
 EXTRA_OECMAKE = " -DPYTHON_INSTALL_DIR=${PYTHON_SITEPACKAGES_DIR} -DWITH_MAN=OFF -DPYTHON_DESIRED=3 \
                   ${@bb.utils.contains('GI_DATA_ENABLED', 'True', '-DWITH_GIR=ON', '-DWITH_GIR=OFF', d)} \
Signature · 1 line
2.30.2
author
#8 lore raw

RFC PATCH 6/26 python3-dbus: inherit setuptools3-base not distuils

In reply to Tim Orling

[YOCTO #14610]

---
 meta/recipes-devtools/python/python3-dbus_1.2.18.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/python/python3-dbus_1.2.18.bb +1 -1
index 9592fbf7169..c4687de13c2 100644
@@ -11,7 +11,7 @@ SRC_URI[sha256sum] = "92bdd1e68b45596c833307a5ff4b217ee6929a1502f5341bae28fd120a
 
 S = "${WORKDIR}/dbus-python-${PV}"
 
-inherit distutils3-base autotools pkgconfig
+inherit setuptools3-base autotools pkgconfig
 
 # documentation needs python3-sphinx, which is not in oe-core or meta-python for now
 # change to use PACKAGECONFIG when python3-sphinx is added to oe-core
Signature · 1 line
2.30.2
author
#9 lore raw

RFC PATCH 7/26 gpgme: inherit setuptools-base not distutils

In reply to Tim Orling

What was distutils-common-base has been merged into setuptools3-base, since we no longer need to support python2 and python3.

[YOCTO #14610]

---
 meta/recipes-support/gpgme/gpgme_1.16.0.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-support/gpgme/gpgme_1.16.0.bb +1 -1
index 0ab30d93b9e..d31e1b3132e 100644
@@ -59,7 +59,7 @@ EXTRA_OECONF += '--enable-languages="${LANGUAGES}" \
                  --disable-lang-python-test \
 '
 
-inherit autotools texinfo binconfig-disabled pkgconfig distutils-common-base ${PYTHON_INHERIT} multilib_header
+inherit autotools texinfo binconfig-disabled pkgconfig setuptools3-base ${PYTHON_INHERIT} multilib_header
 
 export PKG_CONFIG='pkg-config'
 
Signature · 1 line
2.30.2
author
#10 lore raw

RFC PATCH 8/26 python3-pip: inherit setuptools3 not distutils3

In reply to Tim Orling

[YOCTO #14610]

---
 meta/recipes-devtools/python/python3-pip_21.3.1.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/python/python3-pip_21.3.1.bb +1 -1
index 6ddb1d62966..c893135059b 100644
@@ -6,7 +6,7 @@ LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=c4fa2b50f55649f43060fa04b0919b9b"
 
 DEPENDS += "python3 python3-setuptools-native"
 
-inherit pypi distutils3
+inherit pypi setuptools3
 
 SRC_URI += "file://0001-change-shebang-to-python3.patch"
 
Signature · 1 line
2.30.2
author
#11 lore raw

RFC PATCH 9/26 systemtap: use setuptools-base not distutils

In reply to Tim Orling

[YOCTO #14610]

---
 meta/recipes-kernel/systemtap/systemtap_git.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-kernel/systemtap/systemtap_git.bb +1 -1
index d11d9b93a2d..04f7e03ab50 100644
@@ -31,7 +31,7 @@ PACKAGECONFIG[monitor] = "--enable-monitor,--disable-monitor,ncurses json-c"
 PACKAGECONFIG[python3-probes] = "--with-python3-probes,--without-python3-probes,python3-setuptools-native"
 
 inherit autotools gettext pkgconfig systemd
-inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3-probes', 'distutils3-base', '', d)}
+inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3-probes', 'setuptools3-base', '', d)}
 
 # exporter comes with python3-probes
 PACKAGES =+ "${PN}-exporter"
Signature · 1 line
2.30.2
author
#12 lore raw

RFC PATCH 10/26 libcomps: inherit setuptools3-base not distutils

In reply to Tim Orling

[YOCTO #14610]

---
 meta/recipes-devtools/libcomps/libcomps_0.1.18.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/libcomps/libcomps_0.1.18.bb +1 -1
index 3fd4d5b83d4..5fa7fd3e35f 100644
@@ -13,7 +13,7 @@ SRCREV = "dee4ae37f7818709802de28c4d16fa823bd83ae2"
 
 S = "${WORKDIR}/git"
 
-inherit cmake distutils3-base
+inherit cmake setuptools3-base
 
 DEPENDS += "libxml2 expat libcheck"
 
Signature · 1 line
2.30.2
author
#13 lore raw

RFC PATCH 11/26 createrepo-c: inherit setuptools3-base not distutils

In reply to Tim Orling

[YOCTO #14610]

---
 meta/recipes-devtools/createrepo-c/createrepo-c_0.17.7.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/createrepo-c/createrepo-c_0.17.7.bb +1 -1
index 0c27756d2ac..0b18b8baa0d 100644
@@ -15,7 +15,7 @@ S = "${WORKDIR}/git"
 DEPENDS = "expat curl glib-2.0 libxml2 openssl bzip2 zlib file sqlite3 xz rpm"
 DEPENDS:append:class-native = " file-replacement-native"
 
-inherit cmake pkgconfig bash-completion distutils3-base
+inherit cmake pkgconfig bash-completion setuptools3-base
 
 EXTRA_OECMAKE = " -DPYTHON_INSTALL_DIR=${PYTHON_SITEPACKAGES_DIR} -DPYTHON_DESIRED=3 -DWITH_ZCHUNK=OFF -DENABLE_DRPM=OFF -DWITH_LIBMODULEMD=OFF"
 
Signature · 1 line
2.30.2
author
#14 lore raw

RFC PATCH 12/26 librepo: inherit setuptools3-base not distutils

In reply to Tim Orling

[YOCTO #14610]

---
 meta/recipes-devtools/librepo/librepo_1.14.2.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/librepo/librepo_1.14.2.bb +1 -1
index 61a485cfe89..6cd8090b556 100644
@@ -16,7 +16,7 @@ S = "${WORKDIR}/git"
 
 DEPENDS = "curl glib-2.0 openssl attr gpgme libxml2"
 
-inherit cmake distutils3-base pkgconfig
+inherit cmake setuptools3-base pkgconfig
 
 EXTRA_OECMAKE = " \
     -DPYTHON_INSTALL_DIR=${PYTHON_SITEPACKAGES_DIR} \
Signature · 1 line
2.30.2
author
#15 lore raw

RFC PATCH 13/26 btrfs-tools: use setuptools3-base not distutils

In reply to Tim Orling

[YOCTO #14610]

---
 meta/recipes-devtools/btrfs-tools/btrfs-tools_5.15.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/btrfs-tools/btrfs-tools_5.15.bb +1 -1
index 399ba17e3ed..45872e4a972 100644
@@ -43,7 +43,7 @@ PACKAGECONFIG[crypto-libsodium] = "--with-crypto=libsodium,,libsodium"
 PACKAGECONFIG[crypto-libkcapi] = "--with-crypto=libkcapi,,libkcapi"
 
 inherit autotools-brokensep pkgconfig manpages
-inherit ${@bb.utils.contains('PACKAGECONFIG', 'python', 'distutils3-base', '', d)}
+inherit ${@bb.utils.contains('PACKAGECONFIG', 'python', 'setuptools3-base', '', d)}
 
 CLEANBROKEN = "1"
 
Signature · 1 line
2.30.2
author
#16 lore raw

RFC PATCH 14/26 scripts/buildhistory-diff: drop use of distutils

In reply to Tim Orling

The use of distutils.version.LooseVersion to check for GitPython > 0.3.1 is not really needed anymore since any supported distribution has at least 1.0.0 (centos-7 via epel7, debian-9, ubuntu-16.04)

If we want to reinstate this check, alternatives would be to require python3-packaging on all hosts and use packaging.version.Version or use an imported LooseVersion in bb.version.

[YOCTO #14610]

---
 scripts/buildhistory-diff | 5 -----
 1 file changed, 5 deletions(-)
scripts/buildhistory-diff +0 -5
index 3bd40a2a1ea..a6e785aa238 100755
@@ -11,7 +11,6 @@
 import sys
 import os
 import argparse
-from distutils.version import LooseVersion
 
 # Ensure PythonGit is installed (buildhistory_analysis needs it)
 try:
@@ -73,10 +72,6 @@ def main():
     parser = get_args_parser()
     args = parser.parse_args()
 
-    if LooseVersion(git.__version__) < '0.3.1':
-        sys.stderr.write("Version of GitPython is too old, please install GitPython (python-git) 0.3.1 or later in order to use this script\n")
-        sys.exit(1)
-
     if len(args.revisions) > 2:
         sys.stderr.write('Invalid argument(s) specified: %s\n\n' % ' '.join(args.revisions[2:]))
         parser.print_help()
Signature · 1 line
2.30.2
author
#17 lore raw

RFC PATCH 15/26 python3-pygobject: setuptools instead of distutils

In reply to Tim Orling

[YOCTO #14610]

---
 meta/recipes-devtools/python/python3-pygobject_3.42.0.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/python/python3-pygobject_3.42.0.bb +1 -1
index b07969c5efb..74318337bad 100644
@@ -8,7 +8,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=a916467b91076e631dd8edb7424769c7"
 GNOMEBASEBUILDCLASS = "meson"
 GIR_MESON_OPTION = ""
 
-inherit gnomebase distutils3-base gobject-introspection upstream-version-is-even
+inherit gnomebase setuptools3-base gobject-introspection upstream-version-is-even
 
 DEPENDS += "python3 glib-2.0"
 
Signature · 1 line
2.30.2
author
#18 lore raw

RFC PATCH 16/26 bind: inherit setuptools3-base instead of distutils

In reply to Tim Orling

[YOCTO #14610]

---
 meta/recipes-connectivity/bind/bind_9.16.23.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-connectivity/bind/bind_9.16.23.bb +1 -1
index c1bf250c26e..f4db113c7e1 100644
@@ -46,7 +46,7 @@ EXTRA_OECONF = " --with-libtool --disable-devpoll --disable-auto-validation --en
                "
 LDFLAGS:append = " -lz"
 
-inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3native distutils3-base', '', d)}
+inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3native setuptools3-base', '', d)}
 
 # dhcp needs .la so keep them
 REMOVE_LIBTOOL_LA = "0"
Signature · 1 line
2.30.2
author
#19 lore raw

RFC PATCH 17/26 python3-setuptools: do not depend on distutils

In reply to Tim Orling

No longer depend on python3-distutils, current versions of setuptools vendor as _distutils.

[YOCTO #14610]

---
 meta/recipes-devtools/python/python3-setuptools_59.2.0.bb | 1 -
 1 file changed, 1 deletion(-)
meta/recipes-devtools/python/python3-setuptools_59.2.0.bb +0 -1
index 704f58abd31..9ff4095c7a9 100644
@@ -22,7 +22,6 @@ RDEPENDS:${PN} = "\
     ${PYTHON_PN}-compile \
     ${PYTHON_PN}-compression \
     ${PYTHON_PN}-ctypes \
-    ${PYTHON_PN}-distutils \
     ${PYTHON_PN}-email \
     ${PYTHON_PN}-html \
     ${PYTHON_PN}-json \
Signature · 1 line
2.30.2
author
#20 lore raw

RFC PATCH 18/26 sanity.bbclass: drop usage of distutils

In reply to Tim Orling

Refactor to use newly imported bb.version.LooseVersion and replace import distutils.sysconfig with 'import sysconfig`.

https://www.python.org/dev/peps/pep-0632/#id23

[YOCTO #14610]

---
 meta/classes/sanity.bbclass | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
meta/classes/sanity.bbclass +8 -8
index 9fbc9c18e7c..d7fdd5c04b1 100644
@@ -462,7 +462,7 @@ def check_sanity_validmachine(sanity_data):
 # Patch before 2.7 can't handle all the features in git-style diffs.  Some
 # patches may incorrectly apply, and others won't apply at all.
 def check_patch_version(sanity_data):
-    from distutils.version import LooseVersion
+    from bb.version import LooseVersion
     import re, subprocess
 
     try:
@@ -478,7 +478,7 @@ def check_patch_version(sanity_data):
 # Unpatched versions of make 3.82 are known to be broken.  See GNU Savannah Bug 30612.
 # Use a modified reproducer from http://savannah.gnu.org/bugs/?30612 to validate.
 def check_make_version(sanity_data):
-    from distutils.version import LooseVersion
+    from bb.version import LooseVersion
     import subprocess
 
     try:
@@ -539,7 +539,7 @@ def check_wsl(d):
 # built buildtools-extended-tarball)
 #
 def check_gcc_version(sanity_data):
-    from distutils.version import LooseVersion
+    from bb.version import LooseVersion
     import subprocess
     
     build_cc, version = oe.utils.get_host_compiler_version(sanity_data)
@@ -552,7 +552,7 @@ def check_gcc_version(sanity_data):
 # but earlier versions do not; this needs to work properly for sstate
 # Version 1.28 is needed so opkg-build works correctly when reproducibile builds are enabled
 def check_tar_version(sanity_data):
-    from distutils.version import LooseVersion
+    from bb.version import LooseVersion
     import subprocess
     try:
         result = subprocess.check_output(["tar", "--version"], stderr=subprocess.STDOUT).decode('utf-8')
@@ -567,7 +567,7 @@ def check_tar_version(sanity_data):
 # The kernel tools assume git >= 1.8.3.1 (verified needed > 1.7.9.5) see #6162 
 # The git fetcher also had workarounds for git < 1.7.9.2 which we've dropped
 def check_git_version(sanity_data):
-    from distutils.version import LooseVersion
+    from bb.version import LooseVersion
     import subprocess
     try:
         result = subprocess.check_output(["git", "--version"], stderr=subprocess.DEVNULL).decode('utf-8')
@@ -655,10 +655,10 @@ def check_sanity_version_change(status, d):
 
     # Check the python install is complete. Examples that are often removed in
     # minimal installations: glib-2.0-natives requries # xml.parsers.expat and icu
-    # requires distutils.sysconfig.
+    # requires sysconfig module in Python standard library.
     try:
         import xml.parsers.expat
-        import distutils.sysconfig
+        import sysconfig
     except ImportError as e:
         status.addresult('Your Python 3 is not a full install. Please install the module %s (see the Getting Started guide for further information).\n' % e.name)
 
@@ -796,7 +796,7 @@ def check_sanity_everybuild(status, d):
         status.addresult('The system requires at least Python 3.6 to run. Please update your Python interpreter.\n')
 
     # Check the bitbake version meets minimum requirements
-    from distutils.version import LooseVersion
+    from bb.version import LooseVersion
     minversion = d.getVar('BB_MIN_VERSION')
     if (LooseVersion(bb.__version__) < LooseVersion(minversion)):
         status.addresult('Bitbake version %s is required and version %s was found\n' % (minversion, bb.__version__))
Signature · 1 line
2.30.2
author
#21 lore raw

RFC PATCH 19/26 gstreamer1.0-python: inherit setuptools3-base

In reply to Tim Orling

Drop distutils3-base usage as it is now deprecated.

[YOCTO #14610]

---
 meta/recipes-multimedia/gstreamer/gstreamer1.0-python_1.18.5.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-multimedia/gstreamer/gstreamer1.0-python_1.18.5.bb +1 -1
index 045aea44099..1dd7d0d09a3 100644
@@ -23,4 +23,4 @@ EXTRA_OEMESON += "-Dlibpython-dir=${libdir}"
 REQUIRED_DISTRO_FEATURES = "gobject-introspection-data"
 GIR_MESON_OPTION = ""
 
-inherit meson pkgconfig distutils3-base upstream-version-is-even gobject-introspection features_check
+inherit meson pkgconfig setuptools3-base upstream-version-is-even gobject-introspection features_check
Signature · 1 line
2.30.2
author
#22 lore raw

RFC PATCH 20/26 recipetool/create_buildsys_python.py: less distutils

In reply to Tim Orling

distutils is deprecated in Python 3.10 with removal in Python 3.12 (~October 2023). Replace distutils.command.build_py with setuptools.command.build_py.

There is still a check which decides to inherit setuptools3 vs distutils3 that will need to be refactored when we add pyproject.toml and setup.cfg support for more modern PEP 517 packages.

Once distutils3.bbclass is dropped, any recipe inheriting distutils3 will throw a parsing error. The plan is to move distutils*.bbclasses to meta-python. However if meta-python is not in bblayers, the parsing error would still occur.

[YOCTO #14610]

---
 scripts/lib/recipetool/create_buildsys_python.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/lib/recipetool/create_buildsys_python.py +2 -2
index 0b6b042ed17..570be7e81b2 100644
@@ -8,7 +8,7 @@
 import ast
 import codecs
 import collections
-import distutils.command.build_py
+import setuptools.command.build_py
 import email
 import imp
 import glob
@@ -459,7 +459,7 @@ class PythonRecipeHandler(RecipeHandler):
         else:
             package_dir = {}
 
-        class PackageDir(distutils.command.build_py.build_py):
+        class PackageDir(setuptools.command.build_py.build_py):
             def __init__(self, package_dir):
                 self.package_dir = package_dir
 
Signature · 1 line
2.30.2
author
#23 lore raw

RFC PATCH 21/26 waf.bbclass: drop usage of distutils

In reply to Tim Orling

Refactor to use newly imported bb.version.LooseVersion

[YOCTO #14610]

---
 meta/classes/waf.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/waf.bbclass +1 -1
index df0ab8d73ff..f9e240c272a 100644
@@ -43,7 +43,7 @@ BB_HASHBASE_WHITELIST += "WAFLOCK"
 
 python waf_preconfigure() {
     import subprocess
-    from distutils.version import StrictVersion
+    from bb.version import StrictVersion
     subsrcdir = d.getVar('S')
     python = d.getVar('WAF_PYTHON')
     wafbin = os.path.join(subsrcdir, 'waf')
Signature · 1 line
2.30.2
author
#24 lore raw

RFC PATCH 22/26 dnf: drop python3-disutils dependency

In reply to Tim Orling

Upstream dropped the now deprecated distutils:
18995d65 Remove distutils which are deprecated in python3.10 (RhBug:1950229)

Usage was replaced with sysconfig, which is in pyton3-core

[YOCTO #14610]

---
 meta/recipes-devtools/dnf/dnf_4.10.0.bb | 1 -
 1 file changed, 1 deletion(-)
meta/recipes-devtools/dnf/dnf_4.10.0.bb +0 -1
index 6ff2a6b1e6f..3fc24b132df 100644
@@ -38,7 +38,6 @@ RDEPENDS:${PN} += " \
   python3-netclient \
   python3-email \
   python3-threading \
-  python3-distutils \
   python3-logging \
   python3-fcntl \
   librepo \
Signature · 1 line
2.30.2
author
#25 lore raw

RFC PATCH 23/26 python3: refactor python-config patch

In reply to Tim Orling

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]

---
 ...n-implement-legacy-disutils-behavior.patch | 68 +++++++++++++++++++
 .../python/python3/python-config.patch        | 55 ---------------
 .../recipes-devtools/python/python3_3.10.0.bb |  2 +-
 3 files changed, 69 insertions(+), 56 deletions(-)
 create mode 100644 meta/recipes-devtools/python/python3/0001-python-config.in-implement-legacy-disutils-behavior.patch
 delete mode 100644 meta/recipes-devtools/python/python3/python-config.patch
meta/recipes-devtools/python/python3/0001-python-config.in-implement-legacy-disutils-behavior.patch new file +68 -0
new file mode 100644
index 00000000000..71fad65def0
@@ -0,0 +1,68 @@
+From 9bc5f12a31f1c90913bfa90f71ec12cea95de040 Mon Sep 17 00:00:00 2001
+From: Tim Orling <[email protected]>
+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 <[email protected]>
+---
+ 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
+
meta/recipes-devtools/python/python3/python-config.patch deleted +0 -55

55 lines not on this page · raw message

meta/recipes-devtools/python/python3_3.10.0.bb +1 -1
index e3300b6495b..6b965af0509 100644
@@ -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 = " \
Signature · 1 line
2.30.2
author
#26 lore raw

RFC PATCH 24/26 lib/oe/terminal.py: use bb.version.LooseVersion

In reply to Tim Orling

distutils has been deprecated in Python 3.10 and is slated for removal in Python 3.12 (~October 2023).

Refactor to use the newly imported bb.version.LooseVersion instead of distutils.version.LooseVersion.

[YOCTO #14610]

---
 meta/lib/oe/terminal.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/lib/oe/terminal.py +1 -1
index 59aa80de669..6681b0831a5 100644
@@ -5,7 +5,7 @@ import logging
 import oe.classutils
 import shlex
 from bb.process import Popen, ExecutionError
-from distutils.version import LooseVersion
+from bb.version import LooseVersion
 
 logger = logging.getLogger('BitBake.OE.Terminal')
 
Signature · 1 line
2.30.2
author
#27 lore raw

RFC PATCH 25/26 python3native.bbclass: distutils -> sysconfig

In reply to Tim Orling

In the comment it says we patch distutils modules, but we now are patching sysconfig and not using disutils.

[YOCTO #14610]

---
 meta/classes/python3native.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/python3native.bbclass +1 -1
index 13fbaa5f9c7..3783c0c47eb 100644
@@ -4,7 +4,7 @@ PYTHON="${STAGING_BINDIR_NATIVE}/python3-native/python3"
 EXTRANATIVEPATH += "python3-native"
 DEPENDS:append = " python3-native "
 
-# python-config and other scripts are using distutils modules
+# python-config and other scripts are using sysconfig modules
 # which we patch to access these variables
 export STAGING_INCDIR
 export STAGING_LIBDIR
Signature · 1 line
2.30.2
author
#28 lore raw

RFC PATCH 26/26 rootfs_rpm.bbclass: distutils -> sysconfig module

In reply to Tim Orling

Change a comment to reference our custom changes to the sysconfig module, as dnf no longer uses distutils.

[YOCTO #14610]

---
 meta/classes/rootfs_rpm.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/rootfs_rpm.bbclass +1 -1
index 3d8d784f792..bec4d63ed6c 100644
@@ -4,7 +4,7 @@
 
 ROOTFS_PKGMANAGE = "rpm dnf"
 
-# dnf is using our custom distutils, and so will fail without these
+# dnf is using our custom sysconfig module, and so will fail without these
 export STAGING_INCDIR
 export STAGING_LIBDIR
 
Signature · 1 line
2.30.2