diff mbox series

[3/8] python3-numpy: backport a Meson patch to fix pkg-config lookups

Message ID 20260123180448.2997378-4-ross.burton@arm.com
State New
Headers show
Series Rationalise the pkg-config variables | expand

Commit Message

Ross Burton Jan. 23, 2026, 6:04 p.m. UTC
When Meson uses pkg-config to introspect the Python install it resets
PKG_CONFIG_PATH and PKG_CONFIG_LIBDIR to the location that the running
python3 says is the library directory. However, when it writes to
PKG_CONFIG_LIBDIR it uses the _target_ library directory without
prefixing this with the sysroot, which breaks the build if _LIBDIR is
the primary search path.

This has been fixed in Meson since 1.10.0[1] but numpy has a vendored
fork of Meson that is currently at 1.9.2, so backport the specific fix
to solve this problem.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 .../python3-numpy/0001-python-sysroot.patch   | 34 +++++++++++++++++++
 .../python/python3-numpy_2.3.5.bb             |  1 +
 2 files changed, 35 insertions(+)
 create mode 100644 meta/recipes-devtools/python/python3-numpy/0001-python-sysroot.patch
diff mbox series

Patch

diff --git a/meta/recipes-devtools/python/python3-numpy/0001-python-sysroot.patch b/meta/recipes-devtools/python/python3-numpy/0001-python-sysroot.patch
new file mode 100644
index 0000000000..b22c123493
--- /dev/null
+++ b/meta/recipes-devtools/python/python3-numpy/0001-python-sysroot.patch
@@ -0,0 +1,34 @@ 
+From c40218577305f5953ef63d943c26a27c5a931770 Mon Sep 17 00:00:00 2001
+From: Ross Burton <ross.burton@arm.com>
+Date: Wed, 21 Jan 2026 14:12:36 +0000
+Subject: [PATCH] Add sysroot to pkgconfig libdir
+
+When Meson uses pkg-config to introspect the Python install it resets PKG_CONFIG_PATH
+and PKG_CONFIG_LIBDIR. However, when it writes to PKG_CONFIG_LIBDIR it uses the
+_target_ library directory without prefixing this with the sysroot, which breaks 
+the build if _LIBDIR is the primary search path.
+
+This has been fixed in Meson since 1.10.0[1] but numpy has a vendored fork of Meson
+that is currently at 1.9.2, so backport the specific fix to solve this problem.
+
+[1] meson 59c3dd1fd ("python: add a python.build_config option (PEP 739)")
+
+Upstream-Status: Backport
+Signed-off-by: Ross Burton <ross.burton@arm.com>
+---
+ vendored-meson/meson/mesonbuild/dependencies/python.py | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/vendored-meson/meson/mesonbuild/dependencies/python.py b/vendored-meson/meson/mesonbuild/dependencies/python.py
+index 7f9bd20..fdcf714 100644
+--- a/vendored-meson/meson/mesonbuild/dependencies/python.py
++++ b/vendored-meson/meson/mesonbuild/dependencies/python.py
+@@ -412,6 +412,8 @@ def python_factory(env: 'Environment', for_machine: 'MachineChoice',
+     if DependencyMethods.PKGCONFIG in methods:
+         if from_installation:
+             pkg_libdir = installation.info['variables'].get('LIBPC')
++            sysroot = env.properties[for_machine].get_sys_root() or ''
++            pkg_libdir = sysroot + pkg_libdir
+             pkg_embed = '-embed' if embed and mesonlib.version_compare(installation.info['version'], '>=3.8') else ''
+             pkg_name = f'python-{pkg_version}{pkg_embed}'
+ 
diff --git a/meta/recipes-devtools/python/python3-numpy_2.3.5.bb b/meta/recipes-devtools/python/python3-numpy_2.3.5.bb
index 55b8091ff8..78972c98d3 100644
--- a/meta/recipes-devtools/python/python3-numpy_2.3.5.bb
+++ b/meta/recipes-devtools/python/python3-numpy_2.3.5.bb
@@ -11,6 +11,7 @@  SRC_URI = "${GITHUB_BASE_URI}/download/v${PV}/${SRCNAME}-${PV}.tar.gz \
            file://0001-Don-t-search-usr-and-so-on-for-libraries-by-default-.patch \
            file://fix_reproducibility.patch \
            file://run-ptest \
+           file://0001-python-sysroot.patch \
            "
 SRC_URI[sha256sum] = "784db1dcdab56bf0517743e746dfb0f885fc68d948aba86eeec2cba234bdf1c0"