imager: fix numpy header detection

With recent Numpy versions (> 2.0.0), the header files are located in
_core/include instead of core/include, and the configure script does not
detect them. Use the `numpy.get_include()` function for the detection
in that script.
This commit is contained in:
Sébastien Maret
2025-05-25 11:22:32 +02:00
parent da79d11260
commit 02b517263f
2 changed files with 29 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
diff --git a/admin/gildas-env.sh b/admin/gildas-env.sh
index acb06f9..b25ecd5 100644
--- a/admin/gildas-env.sh
+++ b/admin/gildas-env.sh
@@ -441,7 +441,7 @@ EOF
# Now search for Numpy
if python -c "import numpy" > /dev/null 2>&1; then
NUMPY_PRESENT=yes
- NUMPY_INC_DIR=`python -c "import numpy; print(numpy.__path__[0] + '/core/include')"`
+ NUMPY_INC_DIR=`python -c "import numpy; print(numpy.get_include())"`
if [ -e "$NUMPY_INC_DIR/numpy/arrayobject.h" ]; then
NUMPY_INC_PRESENT=yes
else
diff --git a/utilities/etc/setup.py.src b/utilities/etc/setup.py.src
index 9a4da86..110a0d1 100644
--- a/utilities/etc/setup.py.src
+++ b/utilities/etc/setup.py.src
@@ -75,7 +75,7 @@ mod_extras = mod_extras.split()
if (os.environ.get('NUMPY_PRESENT') == "yes"):
import numpy
- mod_inc_dirs.append(numpy.__path__[0] + '/core/include')
+ mod_inc_dirs.append(numpy.get_include())
else:
raise Exception("Numpy python package should be present. Aborting.")
+3
View File
@@ -59,6 +59,9 @@ stdenv.mkDerivation (finalAttrs: {
./clang.patch
# Replace hardcoded cpp with GAG_CPP (see below).
./cpp-darwin.patch
# Fix the numpy header detection with numpy > 2.0.0
# Patch submitted upstream, it will be included in the next release.
./numpy-header.patch
];
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-unused-command-line-argument";