Skip to contentSkip to conversation

python3-thrift: Switch to python_setuptools_build_meta

PATCH New Khem Raj 1 participant 5 messages Jul 29

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/5 python3-thrift: Switch to python_setuptools_build_meta

From: Khem Raj <[email protected]>

thrift's pyproject.toml declares setuptools.build_meta as its build backend, so setuptools3 is the wrong class and do_check_backend warns:

QA Issue: inherits setuptools3 but has pyproject.toml with setuptools.build_meta, use the correct class [pep517-backend]

---
 .../recipes-connectivity/python-thrift/python3-thrift_0.24.0.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta-python/recipes-connectivity/python-thrift/python3-thrift_0.24.0.bb +1 -1
index f59a38a4eb..5f2bdc6e53 100644
@@ -4,7 +4,7 @@ LIC_FILES_CHKSUM = "file://PKG-INFO;beginline=8;endline=8;md5=7145f7cdd263359b62
 
 SRC_URI[sha256sum] = "9ef601c49e988475ff0e741d8e1b45feec23b48514e524341efc274191f1789c"
 
-inherit pypi setuptools3
+inherit pypi python_setuptools_build_meta
 
 # Use different filename to prevent conflicts with thrift itself
 PYPI_SRC_URI:append = ";downloadfilename=${BP}.${PYPI_PACKAGE_EXT}"
author
#1 lore raw

PATCH 2/5 python3-canopen: Switch to python_setuptools_build_meta

From: Khem Raj <[email protected]>

canopen's pyproject.toml declares setuptools.build_meta as its build backend, so setuptools3 is the wrong class and do_check_backend warns:

QA Issue: inherits setuptools3 but has pyproject.toml with setuptools.build_meta, use the correct class [pep517-backend]

Unlike setup.py, pyproject-build honours the declared build requirements, so the setuptools_scm dependency has to be provided explicitly, otherwise do_compile fails with:

ERROR Unmet dependencies ...

	setuptools_scm>=8
		wanted: >=8
		found: not installed

setuptools_scm was silently ignored before, so the package used to ship its metadata as canopen-0.0.0.dist-info. Pin the version to ${PV} so the directory is now correctly named canopen-2.4.1.dist-info.

---
 .../recipes-devtools/python/python3-canopen_2.4.1.bb       | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
meta-python/recipes-devtools/python/python3-canopen_2.4.1.bb +6 -1
index 80c39f6c2c..b0c6f9f10e 100644
@@ -5,7 +5,12 @@ LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=97f135a6ee6f800c377b5512122c7a8d"
 
 SRC_URI[sha256sum] = "20a84bc498b34dadd79cece467d3bbe19591c1c02a8f39331bcc6065c4d8b2eb"
 
-inherit setuptools3 pypi
+DEPENDS += "python3-setuptools-scm-native"
+
+inherit python_setuptools_build_meta pypi
+
+# The sdist has no git metadata for setuptools_scm to look at.
+export SETUPTOOLS_SCM_PRETEND_VERSION = "${PV}"
 
 RDEPENDS:${PN} += "\
   python3-can \
author
#2 lore raw

PATCH 3/5 python3-uefi-firmware: Switch to python_setuptools_build_meta

In reply to Khem Raj

From: Khem Raj <[email protected]>

uefi-firmware-parser's pyproject.toml declares setuptools.build_meta as its build backend, so setuptools3 is the wrong class and do_check_backend warns:

QA Issue: inherits setuptools3 but has pyproject.toml with setuptools.build_meta, use the correct class [pep517-backend]

Unlike setup.py, pyproject-build honours the declared build requirements, so the setuptools_scm dependency has to be provided explicitly, otherwise do_compile fails with:

ERROR Unmet dependencies ...

	setuptools-scm>=8.0
		wanted: >=8.0
		found: not installed

setup.py passes use_scm_version to setup(), which was silently discarded before ("Unknown distribution option: 'use_scm_version'"), so the package used to ship its metadata as uefi_firmware-0.0.0.dist-info. Pin the version to ${PV} so the directory is now correctly named uefi_firmware-1.16.dist-info.

---
 .../recipes-devtools/python/python3-uefi-firmware_1.16.bb | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
meta-python/recipes-devtools/python/python3-uefi-firmware_1.16.bb +7 -1
index 8ad195d7ae..a5d9011094 100644
@@ -11,7 +11,13 @@ SRC_URI = "git://github.com/theopolis/uefi-firmware-parser;protocol=https;branch
 
 SRCREV = "e202e576cefd1fefb3f510237bbd0aea8aedca07"
 
-inherit setuptools3
+DEPENDS += "python3-setuptools-scm-native"
+
+inherit python_setuptools_build_meta
+
+# The tarball is built from a git tag, so let setuptools_scm use ${PV}
+# instead of deriving a version from the checkout.
+export SETUPTOOLS_SCM_PRETEND_VERSION = "${PV}"
 
 RDEPENDS:${PN} += " \
     python3-ctypes \
author
#3 lore raw

PATCH 4/5 python3-wxgtk4: Skip the pep517-backend QA check

In reply to Khem Raj

From: Khem Raj <[email protected]>

wxPython's pyproject.toml declares setuptools.build_meta, so do_check_backend warns:

QA Issue: inherits setuptools3 but has pyproject.toml with setuptools.build_meta, use the correct class [pep517-backend]

Switching to python_setuptools_build_meta is not possible though. The sdist ships a build.py in its top level directory which shadows the "build" module that pyproject-build imports itself, so do_compile dies before it even looks at the recipe:

File ".../recipe-sysroot-native/usr/bin/pyproject-build", line 5, in <module>
from build.__main__ import entrypoint
ModuleNotFoundError: No module named 'build.__main__'; 'build' is not a package

---
 .../python3-wxgtk4/python3-wxgtk4_4.2.5.bb                | 8 ++++++++
 1 file changed, 8 insertions(+)
meta-python/recipes-devtools/python3-wxgtk4/python3-wxgtk4_4.2.5.bb +8 -0
index a84648266e..9a8952df32 100644
@@ -20,6 +20,14 @@ SRC_URI[sha256sum] = "44e836d1bccd99c38790bb034b6ecf70d9060f6734320560f7c4b0d006
 
 inherit pypi setuptools3 cython pkgconfig features_check
 
+# wxPython declares setuptools.build_meta in pyproject.toml, but it cannot be
+# built through pyproject-build: the sdist ships a build.py in its top level
+# directory, which shadows the "build" module pyproject-build itself imports:
+#   from build.__main__ import entrypoint
+#   ModuleNotFoundError: No module named 'build.__main__'; 'build' is not a package
+# Keep driving setup.py directly until upstream stops colliding with that name.
+INSANE_SKIP += "pep517-backend"
+
 REQUIRED_DISTRO_FEATURES = "x11"
 
 export WX_CONFIG = "'${RECIPE_SYSROOT_NATIVE}${bindir}/wx-config --prefix=${STAGING_EXECPREFIXDIR} --baselib=${baselib}'"
author
#4 lore raw

PATCH 5/5 bcc: Stop baking the build directory into the ptest binaries

In reply to Khem Raj

From: Khem Raj <[email protected]>

tests/cc passes -DCMAKE_CURRENT_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}" to every test object so the tests can find archive.zip, the debuginfo libraries and dummy_proc_map.txt at runtime. That put 13 copies of the absolute build directory into the installed test binary:

QA Issue: File /usr/lib/bcc/ptest/tests/cc/test_libbcc_no_libbpf in package bcc-ptest contains reference to TMPDIR [buildpaths]

and, on autobuilders whose TMPDIR sits below $HOME, additionally:

QA Issue: ... contains a reference to the build host HOME directory.

The recipe worked around this by installing the assets to ${D}${B}/tests/cc, i.e. by reproducing the build path inside the image, and by demoting buildpaths to a warning.

Add a patch introducing a TEST_ASSET_DIR cache variable, defaulting to CMAKE_CURRENT_BINARY_DIR so the upstream default is unchanged, and point it at ${PTEST_PATH}/tests/cc. The assets are now installed next to the test binaries and no build path is embedded, so the buildpaths overrides can go away.

Also install dummy_proc_map.txt, which the tests reference but which was never shipped.

---
 ...verriding-the-runtime-location-of-te.patch | 49 +++++++++++++++++++
 .../recipes-devtools/bcc/bcc_0.37.0.bb        | 24 +++++----
 2 files changed, 60 insertions(+), 13 deletions(-)
 create mode 100644 meta-oe/dynamic-layers/meta-python/recipes-devtools/bcc/bcc/0001-tests-cc-Allow-overriding-the-runtime-location-of-te.patch
meta-oe/dynamic-layers/meta-python/recipes-devtools/bcc/bcc/0001-tests-cc-Allow-overriding-the-runtime-location-of-te.patch new file +49 -0
new file mode 100644
index 0000000000..71fc2f5b7e
@@ -0,0 +1,49 @@
+From ba4c3827dd93a21e35d324b41b90ffbd1dff5c4f Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Tue, 28 Jul 2026 21:04:15 -0700
+Subject: [PATCH] tests/cc: Allow overriding the runtime location of test
+ assets
+
+tests/cc bakes CMAKE_CURRENT_BINARY_DIR into every test object so that the
+tests can find archive.zip, the debuginfo test libraries and
+dummy_proc_map.txt at runtime.
+
+That makes the build directory part of the installed test binaries. For
+distributions which build the tests in one place and run them somewhere else
+this is both useless and a reproducibility problem: the absolute build path
+ends up embedded in a shipped binary, and the assets have to be installed at
+that same path for the tests to pass.
+
+Introduce a TEST_ASSET_DIR cache variable which defaults to
+CMAKE_CURRENT_BINARY_DIR, so the default behaviour is unchanged, and use it
+for the macro definition. Packagers can now point it at wherever the assets
+are installed.
+
+The macro keeps its current name to avoid churn in the test sources.
+
+Upstream-Status: Submitted [https://github.com/iovisor/bcc/issues]
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+ tests/cc/CMakeLists.txt | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/tests/cc/CMakeLists.txt b/tests/cc/CMakeLists.txt
+index b4dd3f9..8f56fc9 100644
+--- a/tests/cc/CMakeLists.txt
++++ b/tests/cc/CMakeLists.txt
+@@ -19,7 +19,13 @@ else()
+ endif()
+
+ add_test(NAME c_test_static COMMAND ${TEST_WRAPPER} c_test_static sudo ${CMAKE_CURRENT_BINARY_DIR}/test_static)
+-add_compile_options(-DCMAKE_CURRENT_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}")
++# The tests locate their assets (archive.zip, the debuginfo libraries,
++# dummy_proc_map.txt, ...) through this macro. Let the runtime location be
++# overridden so that distributions can install the assets next to the test
++# binaries instead of baking the build directory into them.
++set(TEST_ASSET_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE STRING
++    "Directory containing the test assets at runtime")
++add_compile_options(-DCMAKE_CURRENT_BINARY_DIR="${TEST_ASSET_DIR}")
+
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result -fPIC")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-result -fPIC")
meta-oe/dynamic-layers/meta-python/recipes-devtools/bcc/bcc_0.37.0.bb +11 -13
index 9ecc30b58b..9315a6e603 100644
@@ -22,6 +22,7 @@ RDEPENDS:${PN}-ptest = "kernel-devsrc packagegroup-core-buildessential cmake bas
 SRC_URI = "gitsm://github.com/iovisor/bcc;branch=master;protocol=https;lfs=0;tag=v${PV} \
            file://0001-CMakeLists.txt-override-the-PY_CMD_ESCAPED.patch \
            file://0001-Vendor-just-enough-extra-headers-to-allow-libbpf-to-.patch \
+           file://0001-tests-cc-Allow-overriding-the-runtime-location-of-te.patch \
            file://run-ptest \
            file://ptest_wrapper.sh \
            "
@@ -44,6 +45,11 @@ EXTRA_OECMAKE = " \
     -DPYTHON_FLAGS=--install-lib=${PYTHON_SITEPACKAGES_DIR} \
 "
 
+# The C tests hardcode the location of their assets at build time. Point that at
+# where do_install_ptest puts them so the build directory does not end up baked
+# into the installed test binaries.
+EXTRA_OECMAKE += "-DTEST_ASSET_DIR=${PTEST_PATH}/tests/cc"
+
 # Avoid stripping debuginfo.so to fix some tests.
 INHIBIT_PACKAGE_STRIP = "1"
 INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
@@ -58,10 +64,11 @@ do_install:append() {
 
 do_install_ptest() {
     install -d ${D}${PTEST_PATH}/tests/cc
-    # ptest searches for shared libs and archive files in the build folder.
-    # Hence, these files are copied to the image to fix these tests.
-    install -d ${D}${B}/tests/cc
-    install ${B}/tests/cc/archive.zip ${B}/tests/cc/libdebuginfo_test_lib.so ${B}/tests/cc/with_gnu_debuglink.so ${B}/tests/cc/with_gnu_debugdata.so ${B}/tests/cc/debuginfo.so ${D}${B}/tests/cc
+    # The C tests look their assets up under TEST_ASSET_DIR, which is pointed at
+    # ${PTEST_PATH}/tests/cc at configure time, so install them next to the test
+    # binaries rather than at the (build host specific) build directory path.
+    install ${B}/tests/cc/archive.zip ${B}/tests/cc/libdebuginfo_test_lib.so ${B}/tests/cc/with_gnu_debuglink.so ${B}/tests/cc/with_gnu_debugdata.so ${B}/tests/cc/debuginfo.so ${D}${PTEST_PATH}/tests/cc
+    install -m 0644 ${B}/tests/cc/dummy_proc_map.txt ${D}${PTEST_PATH}/tests/cc
     install -d ${D}/opt
     install ${B}/tests/cc/test_libbcc_no_libbpf ${B}/tests/cc/libusdt_test_lib.so ${D}${PTEST_PATH}/tests/cc
     cp -rf ${S}/tests/python ${D}${PTEST_PATH}/tests/python
@@ -75,18 +82,9 @@ do_install_ptest() {
 }
 
 FILES:${PN} += "${PYTHON_SITEPACKAGES_DIR}"
-FILES:${PN} += "${B}/tests/cc"
 FILES:${PN}-ptest += "${libdir}/libbcc.so"
 FILES:${PN}-ptest += "${libdir}/tools/"
 FILES:${PN}-ptest += "/opt/"
 FILES:${PN}-doc += "${datadir}/${PN}/man"
 
 COMPATIBLE_HOST = "(x86_64.*|aarch64.*|powerpc64.*|riscv64.*)-linux"
-
-# WARNING: bcc-0.30.0+git-r0 do_package_qa: QA Issue: File /usr/lib/bcc/ptest/tests/cc/test_libbcc_no_libbpf in package bcc-ptest contains reference to TMPDIR [buildpaths]
-# this one is difficult to resolve, because the tests use CMAKE_CURRENT_BINARY_DIR directly in .cc e.g.:
-# https://github.com/iovisor/bcc/commit/7271bfc946a19413761be2e3c60c48bf72c5eea1#diff-233a0bfa490f3d7466c49935b64c86dd93956bbc0461f5af703b344cf6601461
-# we would probably need to use separate variable for "runtime" path for test assets from the standard CMAKE_CURRENT_BINARY_DIR variable or use relative
-# path from the test binary
-WARN_QA:append = "${@bb.utils.contains('PTEST_ENABLED', '1', ' buildpaths', '', d)}"
-ERROR_QA:remove = "${@bb.utils.contains('PTEST_ENABLED', '1', 'buildpaths', '', d)}"