diff mbox series

[3/7] setuptools3_legacy: add pyproject.toml check

Message ID 20250724161543.2253776-3-ross.burton@arm.com
State New
Headers show
Series [1/7] python_pep517: set CONFIGURE_FILES | expand

Commit Message

Ross Burton July 24, 2025, 4:15 p.m. UTC
Copy the pyproject.toml check from setuptools3.bbclass so that the legacy
class will also warn if there's a modern build framework available.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta/classes-recipe/setuptools3_legacy.bbclass | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/meta/classes-recipe/setuptools3_legacy.bbclass b/meta/classes-recipe/setuptools3_legacy.bbclass
index 8197f443c91..6b51b9796bc 100644
--- a/meta/classes-recipe/setuptools3_legacy.bbclass
+++ b/meta/classes-recipe/setuptools3_legacy.bbclass
@@ -30,6 +30,20 @@  SETUPTOOLS_PYTHON:class-native = "nativepython3"
 
 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_legacy 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_legacy_do_configure() {
     :
 }