diff mbox series

python3-numpy: remove more sources of non-reproducibility

Message ID 20260910150316.2400274-1-ross.burton@arm.com
State New
Headers show
Series python3-numpy: remove more sources of non-reproducibility | expand

Commit Message

Ross Burton Sept. 10, 2026, 3:03 p.m. UTC
It was noticed that __config__.py contains details of the build machine
hardware, which is another source of non-reproducibility.

As this file is only used to dump the build configuration on errors, we
can remove entries that leak build details entirely.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 .../python/python3-numpy_2.5.3.bb             | 21 ++++++++-----------
 1 file changed, 9 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/meta/recipes-devtools/python/python3-numpy_2.5.3.bb b/meta/recipes-devtools/python/python3-numpy_2.5.3.bb
index c88b0bf1a29..338bdd2bbd0 100644
--- a/meta/recipes-devtools/python/python3-numpy_2.5.3.bb
+++ b/meta/recipes-devtools/python/python3-numpy_2.5.3.bb
@@ -26,20 +26,17 @@  PACKAGECONFIG[svml] = "-Ddisable-svml=false,-Ddisable-svml=true"
 # the overflow tests fail with compiler-rt on aarch64
 LDFLAGS:append:toolchain-clang:aarch64 = " -rtlib=libgcc -unwindlib=libgcc"
 
-# Remove references to buildpaths from numpy's __config__.py
-do_install:append() {
+# To ensure reproducibility, remove entries from __config__ which expose build
+# machine details, such as build paths, host paths, and hardware configuration.
+strip_build_info() {
     sed -i \
-        -e 's|${S}=||g' \
-        -e 's|${B}=||g' \
-        -e 's|${HOSTTOOLS_DIR}||g' \
-        -e 's|${RECIPE_SYSROOT_NATIVE}=||g' \
-        -e 's|${RECIPE_SYSROOT_NATIVE}||g' \
-        -e 's|${RECIPE_SYSROOT}=||g' \
-        -e 's|${RECIPE_SYSROOT}||g' \
-        ${D}${PYTHON_SITEPACKAGES_DIR}/numpy/__config__.py
-
-    nativepython3 -mcompileall -s ${D} ${D}${PYTHON_SITEPACKAGES_DIR}/numpy/__config__.py
+        -e 's/@.*_ARGS@//' \
+        -e 's/@.*_CMD_ARRAY@//' \
+        -e 's/@BUILD_CPU.*@//' \
+        -e 's/@PYTHON_PATH@//' \
+        ${S}/numpy/__config__.py.in
 }
+do_patch[postfuncs] += "strip_build_info"
 
 do_install_ptest:append() {
     sed -i \