Skip to contentSkip to conversation

setuptools3: check for a PEP517 build system selection

PATCH New Ross Burton 1 participant 4 messages Jul 25, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 setuptools3: check for a PEP517 build system selection

Some recipes use setuptools3 but should be using a PEP517-compliant backend, be it the setuptools itself via python_setuptools_build_meta or an alternative backend such as flit/hatch/poetry.

As we can't currently assume Python 3.11 on the build host we need to parse the pyproject.toml manually, but this should be sufficient for the limited parsing needed.

This task emits a QA error if a build backend is set, and can be ignored by using INSANE_SKIP if needed.

[ YOCTO #14736 ]

---
 meta/classes-recipe/setuptools3.bbclass | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
meta/classes-recipe/setuptools3.bbclass +14 -0
index d71a0895398..64a78e9a367 100644
@@ -12,6 +12,20 @@ SETUPTOOLS_BUILD_ARGS ?= ""
 
 SETUPTOOLS_SETUP_PATH ?= "${S}"
 
+python do_check_backend() {
+    import re
+    filename = d.expand("${SETUPTOOLS_SETUP_PATH}/pyproject.toml")
+    if os.path.exists(filename):
+        for line in open(filename):
+            match = re.match(r"build-backend\s*=\s*\W([\w.]+)\W", line)
+            if not match: continue
+
+            msg = f"inherits setuptools3 but has pyproject.toml with {match[1]}, use the correct class"
+            if "pep517-backend" not in (d.getVar("INSANE_SKIP") or "").split():
+                oe.qa.handle_error("pep517-backend", msg, d)
+}
+addtask check_backend after do_patch before do_configure
+
 setuptools3_do_configure() {
     :
 }
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/4 insane: add pep517-backend to WARN_QA

Enable the new pep517-backend warning from setuptools3, initially as a warning so as not to break builds straight away.

---
 meta/classes-global/insane.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes-global/insane.bbclass +1 -1
index 7bf33f9bc0f..ad38879fa4b 100644
@@ -26,7 +26,7 @@
 
 # Elect whether a given type of error is a warning or error, they may
 # have been set by other files.
-WARN_QA ?= "32bit-time native-last"
+WARN_QA ?= "32bit-time native-last pep517-backend"
 ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \
             textrel incompatible-license files-invalid \
             infodir build-deps src-uri-bad symlink-to-sysroot multilib \
Signature · 1 line
2.34.1
#2 lore raw

PATCH 3/4 python3-numpy: ignore pep517-backend warnings

In reply to Ross Burton

Upstream has a pyproject.toml but it's marked as experimental and does not currently work at all with the meson-python release we currently have.

---
 meta/recipes-devtools/python/python3-numpy_1.26.4.bb | 3 +++
 1 file changed, 3 insertions(+)
meta/recipes-devtools/python/python3-numpy_1.26.4.bb +3 -0
index ccd08147af6..914245507c7 100644
@@ -61,4 +61,7 @@ RDEPENDS:${PN}-ptest += "python3-pytest \
                          ldd \
 "
 
+# Upstream has a pyproject.toml but as of 1.26.4 it's marked as experimental
+INSANE_SKIP = "pep517-backend"
+
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.34.1
#3 lore raw

PATCH 4/4 bmaptool: temporarily silence the pep517-backend warning

In reply to Ross Burton

Whilst bmaptool has a pyproject.toml that uses poetry, the setuptools build path appears to be more complete. Upstream has moved to hatch and removed setup.py entirely so the next release can drop this.

---
 meta/recipes-support/bmaptool/bmaptool_git.bb | 3 +++
 1 file changed, 3 insertions(+)
meta/recipes-support/bmaptool/bmaptool_git.bb +3 -0
index fd53c21c066..c38f05e1a1d 100644
@@ -26,4 +26,7 @@ inherit setuptools3
 RREPLACES:${PN} = "bmap-tools"
 RCONFLICTS:${PN} = "bmap-tools"
 
+# Poetry backend appears incomplete, upstream has moved to hatch
+INSANE_SKIP = "pep517-backend"
+
 BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.34.1