[Buildroot] [git commit] package/python-numpy: fixup npymath.ini for numpy extensions

Arnout Vandecappelle (Essensium/Mind) arnout at mind.be
Fri Jan 7 21:41:31 UTC 2022


commit: https://git.buildroot.net/buildroot/commit/?id=2426002d6fc81d0b023e3f3b3ee4e94ab29438cb
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

In order to build the numpy distutils extension packages like
python-scipy, python-numba, it requires an explicit pkg-config
path fixup for npymath.ini.

This pkg-config path fixup would update the prefix path of
npymath.ini with actual target staging area where numpy core
was built, so that numpy distutils extension packages would
explicitly link this config path for their package environment.

Without this extension packages cannot find -lnpymath since
it uses host libraries (like libnpymath.a).

So, attach the post install staging hook with pkg-config
path fixup for npymath.ini.

Signed-off-by: Esben Haabendal <esben at geanix.com>
Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout at mind.be>
---
 package/python-numpy/python-numpy.mk | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/package/python-numpy/python-numpy.mk b/package/python-numpy/python-numpy.mk
index ae72b87db0..f367b556ef 100644
--- a/package/python-numpy/python-numpy.mk
+++ b/package/python-numpy/python-numpy.mk
@@ -34,6 +34,21 @@ define PYTHON_NUMPY_CONFIGURE_CMDS
 	echo "include_dirs = $(STAGING_DIR)/usr/include" >> $(@D)/site.cfg
 endef
 
+# Fixup the npymath.ini prefix path with actual target staging area where
+# numpy core was built. Without this, target builds using numpy distutils
+# extensions like python-scipy, python-numba cannot find -lnpymath since
+# it uses host libraries (like libnpymath.a).
+# So, the numpy distutils extension packages would explicitly link this
+# config path for their package environment.
+PYTHON_NUMPY_STAGING_DIR = $(STAGING_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages/numpy
+PYTHON_NUMPY_NPY_PKG_CONFIG_PATH=$(PYTHON_NUMPY_STAGING_DIR)/core/lib/npy-pkg-config
+define PYTHON_NUMPY_FIXUP_NPY_PKG_CONFIG_FILES
+	sed -e '/^pkgdir=/d' \
+	    -e '/^prefix=/i pkgdir=$(PYTHON_NUMPY_STAGING_DIR)/core' \
+	    -i $(PYTHON_NUMPY_NPY_PKG_CONFIG_PATH)/npymath.ini
+endef
+PYTHON_NUMPY_POST_INSTALL_STAGING_HOOKS += PYTHON_NUMPY_FIXUP_NPY_PKG_CONFIG_FILES
+
 # Some package may include few headers from NumPy, so let's install it
 # in the staging area.
 PYTHON_NUMPY_INSTALL_STAGING = YES



More information about the buildroot mailing list