Skip to contentSkip to conversation

python3-packaging: remove duplicate python3-setuptools-native DEPENDS

PATCH New Ross Burton 1 participant 8 messages Mar 16, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/8 python3-packaging: remove duplicate python3-setuptools-native DEPENDS

setuptools_build_meta.bbclass already sets this dependency.

---
 meta/recipes-devtools/python/python3-packaging_21.3.bb | 1 -
 1 file changed, 1 deletion(-)
meta/recipes-devtools/python/python3-packaging_21.3.bb +0 -1
index c7d0cb7ef7..a81fd94d37 100644
@@ -9,5 +9,4 @@ inherit pypi setuptools_build_meta
 
 BBCLASSEXTEND = "native nativesdk"
 
-DEPENDS += "${PYTHON_PN}-setuptools-native"
 RDEPENDS:${PN} += "${PYTHON_PN}-pyparsing"
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/8 classes/python_pep517: implement a standard do_compile

As all PEP517-compliant build systems have a universal API, we can ask that users of this class set PEP517_BUILD_API to the class that implements this API and call it ourselves, instead of users needing to implement near-identical do_compile tasks themselves.

---
 meta/classes/python_pep517.bbclass | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
meta/classes/python_pep517.bbclass +12 -1
index ac7c1e44c6..83c6dcb5c7 100644
@@ -6,6 +6,9 @@ DEPENDS:append = " python3-installer-native"
 # Where to execute the build process from
 PEP517_SOURCE_PATH ?= "${S}"
 
+# The PEP517 build API entry point
+PEP517_BUILD_API ?= "unset"
+
 # The directory where wheels should be written too. Build classes
 # will ideally [cleandirs] this but we don't do that here in case
 # a recipe wants to install prebuilt wheels.
@@ -16,6 +19,14 @@ PEP517_INSTALL_PYTHON:class-native = "nativepython3"
 
 INSTALL_WHEEL_COMPILE_BYTECODE ?= "--compile-bytecode=0"
 
+# When we have Python 3.11 we can parse pyproject.toml to determine the build
+# API entry point directly
+python_pep517_do_compile () {
+    cd ${PEP517_SOURCE_PATH}
+    nativepython3 -c "import ${PEP517_BUILD_API} as api; api.build_wheel('${PEP517_WHEEL_PATH}')"
+}
+do_compile[cleandirs] += "${PEP517_WHEEL_PATH}"
+
 python_pep517_do_install () {
     COUNT=$(find ${PEP517_WHEEL_PATH} -name '*.whl' | wc -l)
     if test $COUNT -eq 0; then
@@ -33,4 +44,4 @@ python_pep517_do_bootstrap_install () {
     unzip -d ${D}${PYTHON_SITEPACKAGES_DIR} ${PEP517_WHEEL_PATH}/*.whl
 }
 
-EXPORT_FUNCTIONS do_install
+EXPORT_FUNCTIONS do_compile do_install
Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/8 classes/flit_core: use python_pep517_do_compile

In reply to Ross Burton

Instead of implementing our own do_compile, set PEP517_BUILD_API and use the generic do_compile.

---
 meta/classes/flit_core.bbclass | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
meta/classes/flit_core.bbclass +3 -8
index 5a602f54ab..81fdf93e47 100644
@@ -2,15 +2,10 @@ inherit python_pep517 python3native python3-dir setuptools3-base
 
 DEPENDS += "python3 python3-flit-core-native"
 
+PEP517_BUILD_API = "flit_core.buildapi"
+
 flit_core_do_configure () {
     :
 }
 
-# TODO: ideally this uses pypa/build
-flit_core_do_compile () {
-    cd ${PEP517_SOURCE_PATH}
-    nativepython3 -mflit_core.wheel --outdir ${PEP517_WHEEL_PATH}
-}
-do_compile[cleandirs] += "${PEP517_WHEEL_PATH}"
-
-EXPORT_FUNCTIONS do_configure do_compile
+EXPORT_FUNCTIONS do_configure
Signature · 1 line
2.25.1
#3 lore raw

PATCH 4/8 classes/python_poetry_core: use python_pep517_do_compile

In reply to Ross Burton

Instead of implementing our own do_compile, set PEP517_BUILD_API and use the generic do_compile.

---
 meta/classes/python_poetry_core.bbclass | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
meta/classes/python_poetry_core.bbclass +3 -7
index 47b2fe46d5..3fecb6c6bb 100644
@@ -2,14 +2,10 @@ inherit python_pep517 python3native setuptools3-base
 
 DEPENDS += "python3-poetry-core-native"
 
+PEP517_BUILD_API = "poetry.core.masonry.api"
+
 python_poetry_core_do_configure () {
     :
 }
 
-# TODO: ideally this uses pypa/build
-python_poetry_core_do_compile () {
-    nativepython3 -c "from poetry.core.masonry import api; api.build_wheel('${PEP517_WHEEL_PATH}')"
-}
-do_compile[cleandirs] += "${PEP517_WHEEL_PATH}"
-
-EXPORT_FUNCTIONS do_configure do_compile
+EXPORT_FUNCTIONS do_configure
Signature · 1 line
2.25.1
#4 lore raw

PATCH 5/8 classes/setuptools_build_meta: use python_pep517_do_compile

In reply to Ross Burton

Instead of implementing our own do_compile, set PEP517_BUILD_API and use the generic do_compile.

---
 meta/classes/setuptools_build_meta.bbclass | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
meta/classes/setuptools_build_meta.bbclass +3 -8
index 8791a2965f..62b037363d 100644
@@ -2,15 +2,10 @@ inherit setuptools3-base python_pep517
 
 DEPENDS += "python3-setuptools-native python3-wheel-native"
 
+PEP517_BUILD_API = "setuptools.build_meta"
+
 setuptools_build_meta_do_configure () {
     :
 }
 
-# TODO: ideally this uses pypa/build
-setuptools_build_meta_do_compile () {
-    cd ${PEP517_SOURCE_PATH}
-    nativepython3 -c "from setuptools import build_meta; build_meta.build_wheel('${PEP517_WHEEL_PATH}')"
-}
-do_compile[cleandirs] += "${PEP517_WHEEL_PATH}"
-
-EXPORT_FUNCTIONS do_configure do_compile
+EXPORT_FUNCTIONS do_configure
Signature · 1 line
2.25.1
#5 lore raw

PATCH 6/8 classes/python_pep517: add more comments

In reply to Ross Burton

Remove mention of prebuilt wheels, this is for the full PEP517 build process and recipes that want to install prebuilt wheels can use pypa/installer directly.

---
 meta/classes/python_pep517.bbclass | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
meta/classes/python_pep517.bbclass +6 -3
index 83c6dcb5c7..73bcf9ba07 100644
@@ -1,5 +1,8 @@
 # Common infrastructure for Python packages that use PEP-517 compliant packaging.
 # https://www.python.org/dev/peps/pep-0517/
+#
+# This class will build a wheel in do_compile, and use pypa/installer to install
+# it in do_install.
 
 DEPENDS:append = " python3-installer-native"
 
@@ -9,14 +12,14 @@ PEP517_SOURCE_PATH ?= "${S}"
 # The PEP517 build API entry point
 PEP517_BUILD_API ?= "unset"
 
-# The directory where wheels should be written too. Build classes
-# will ideally [cleandirs] this but we don't do that here in case
-# a recipe wants to install prebuilt wheels.
+# The directory where wheels will be written
 PEP517_WHEEL_PATH ?= "${WORKDIR}/dist"
 
+# The interpreter to use for installed scripts
 PEP517_INSTALL_PYTHON = "python3"
 PEP517_INSTALL_PYTHON:class-native = "nativepython3"
 
+# pypa/installer option to control the bytecode compilation
 INSTALL_WHEEL_COMPILE_BYTECODE ?= "--compile-bytecode=0"
 
 # When we have Python 3.11 we can parse pyproject.toml to determine the build
Signature · 1 line
2.25.1
#6 lore raw

PATCH 7/8 classes/flit_core: rename to python_flit_core

In reply to Ross Burton

To be more uniform with the other new Python classes, rename this to python_flit_core and update the recipes that use it.

---
 meta/classes/{flit_core.bbclass => python_flit_core.bbclass} | 2 +-
 meta/recipes-devtools/python/python3-flit-core_3.7.1.bb      | 2 +-
 meta/recipes-devtools/python/python3-installer_0.5.1.bb      | 2 +-
 meta/recipes-devtools/python/python3-tomli_2.0.1.bb          | 2 +-
 meta/recipes-devtools/python/python3-wheel_0.37.1.bb         | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
 rename meta/classes/{flit_core.bbclass => python_flit_core.bbclass} (84%)
meta/classes/python_flit_core.bbclass renamed from meta/classes/flit_core.bbclass +1 -1
similarity index 84%
rename from meta/classes/flit_core.bbclass
rename to meta/classes/python_flit_core.bbclass
index 81fdf93e47..eef361bb1b 100644
@@ -4,7 +4,7 @@ DEPENDS += "python3 python3-flit-core-native"
 
 PEP517_BUILD_API = "flit_core.buildapi"
 
-flit_core_do_configure () {
+python_flit_core_do_configure () {
     :
 }
 
meta/recipes-devtools/python/python3-flit-core_3.7.1.bb +1 -1
index dc815acf08..8d107384a6 100644
@@ -10,7 +10,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=41eb78fa8a872983a882c694a8305f08"
 
 SRC_URI[sha256sum] = "3c9bd9c140515bfe62dd938c6610d10d6efb9e35cc647fc614fe5fb3a5036682"
 
-inherit pypi flit_core
+inherit pypi python_flit_core
 
 # Need to install by hand as there's a dependency loop
 DEPENDS:remove:class-native = " python3-installer-native"
meta/recipes-devtools/python/python3-installer_0.5.1.bb +1 -1
index 12d9fce249..f4f9e1bde6 100644
@@ -10,7 +10,7 @@ SRC_URI += "file://interpreter.patch"
 
 SRC_URI[sha256sum] = "f970995ec2bb815e2fdaf7977b26b2091e1e386f0f42eafd5ac811953dc5d445"
 
-inherit pypi flit_core
+inherit pypi python_flit_core
 
 DEPENDS:remove:class-native = "python3-installer-native"
 DEPENDS:append:class-native = " unzip-native"
meta/recipes-devtools/python/python3-tomli_2.0.1.bb +1 -1
index f8b423bbef..6118a6a9c3 100644
@@ -6,7 +6,7 @@ BUGTRACKER = "https://github.com/hukkin/tomli/issues"
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=aaaaf0879d17df0110d1aa8c8c9f46f5"
 
-inherit pypi flit_core
+inherit pypi python_flit_core
 
 SRC_URI[sha256sum] = "de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"
 
meta/recipes-devtools/python/python3-wheel_0.37.1.bb +1 -1
index efd6c2f968..2f7dd122ba 100644
@@ -6,7 +6,7 @@ LIC_FILES_CHKSUM = "file://PKG-INFO;beginline=10;endline=10;md5=8227180126797a01
 
 SRC_URI[sha256sum] = "e9a504e793efbca1b8e0e9cb979a249cf4a0a7b5b8c9e8b65a5e39d49529c1c4"
 
-inherit flit_core pypi
+inherit python_flit_core pypi
 
 SRC_URI += " file://0001-Backport-pyproject.toml-from-flit-backend-branch.patch"
 
Signature · 1 line
2.25.1
#7 lore raw

PATCH 8/8 classes/python_pep517: consolidate stub do_configure

In reply to Ross Burton

As PEP517 doesn't have an explicit configure step, we can stub out the do_configure task once instead of the calling classes doing it.

---
 meta/classes/python_flit_core.bbclass      | 6 ------
 meta/classes/python_pep517.bbclass         | 8 +++++++-
 meta/classes/python_poetry_core.bbclass    | 6 ------
 meta/classes/setuptools_build_meta.bbclass | 6 ------
 4 files changed, 7 insertions(+), 19 deletions(-)
meta/classes/python_flit_core.bbclass +0 -6
index eef361bb1b..96652aa204 100644
@@ -3,9 +3,3 @@ inherit python_pep517 python3native python3-dir setuptools3-base
 DEPENDS += "python3 python3-flit-core-native"
 
 PEP517_BUILD_API = "flit_core.buildapi"
-
-python_flit_core_do_configure () {
-    :
-}
-
-EXPORT_FUNCTIONS do_configure
meta/classes/python_pep517.bbclass +7 -1
index 73bcf9ba07..34ffdc9c0d 100644
@@ -22,6 +22,12 @@ PEP517_INSTALL_PYTHON:class-native = "nativepython3"
 # pypa/installer option to control the bytecode compilation
 INSTALL_WHEEL_COMPILE_BYTECODE ?= "--compile-bytecode=0"
 
+# PEP517 doesn't have a specific configure step, so set an empty do_configure to avoid
+# running base_do_configure.
+python_pep517_do_configure () {
+    :
+}
+
 # When we have Python 3.11 we can parse pyproject.toml to determine the build
 # API entry point directly
 python_pep517_do_compile () {
@@ -47,4 +53,4 @@ python_pep517_do_bootstrap_install () {
     unzip -d ${D}${PYTHON_SITEPACKAGES_DIR} ${PEP517_WHEEL_PATH}/*.whl
 }
 
-EXPORT_FUNCTIONS do_compile do_install
+EXPORT_FUNCTIONS do_configure do_compile do_install
meta/classes/python_poetry_core.bbclass +0 -6
index 3fecb6c6bb..577663b8f1 100644
@@ -3,9 +3,3 @@ inherit python_pep517 python3native setuptools3-base
 DEPENDS += "python3-poetry-core-native"
 
 PEP517_BUILD_API = "poetry.core.masonry.api"
-
-python_poetry_core_do_configure () {
-    :
-}
-
-EXPORT_FUNCTIONS do_configure
meta/classes/setuptools_build_meta.bbclass +0 -6
index 62b037363d..b2bba35a0b 100644
@@ -3,9 +3,3 @@ inherit setuptools3-base python_pep517
 DEPENDS += "python3-setuptools-native python3-wheel-native"
 
 PEP517_BUILD_API = "setuptools.build_meta"
-
-setuptools_build_meta_do_configure () {
-    :
-}
-
-EXPORT_FUNCTIONS do_configure
Signature · 1 line
2.25.1