Skip to content

Commit ff1b9fa

Browse files
BLD: add option to specify numpy header location
In some cases the numpy module might not be usable during build-time, especially when cross-compiling. (E.g. when compiling for arm32 on a x86-64 machine, the arm32 module is not usable at build time). This makes meson fail, as it isn't able to figure out the location of numpy headers. To allow an alternative way to find these headers, introduce a meson build option, where the location of the numpy headers can be specified. In case numpy module cannot be loaded for some reason to query the include folder location, fall back to the value of this meson option. Signed-off-by: Gyorgy Sarvari <[email protected]>
1 parent f1b00b8 commit ff1b9fa

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

doc/source/whatsnew/v3.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Other enhancements
8181
- Support passing a :class:`Iterable[Hashable]` input to :meth:`DataFrame.drop_duplicates` (:issue:`59237`)
8282
- Support reading Stata 102-format (Stata 1) dta files (:issue:`58978`)
8383
- Support reading Stata 110-format (Stata 7) dta files (:issue:`47176`)
84+
- Support specifying numpy header location when building with Meson (:issue:`55305`)
8485

8586
.. ---------------------------------------------------------------------------
8687
.. _whatsnew_300.notable_bug_fixes:

meson.options

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
option('numpy_inc_dir', type : 'string', description : 'The absolute path to the numpy headers')

pandas/meson.build

+10-3
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,24 @@ incdir_numpy = run_command(
44
'-c',
55
'''
66
import os
7-
import numpy as np
7+
8+
try:
9+
import numpy as np
10+
base_incdir = np.get_include()
11+
except Exception:
12+
base_incdir = os.getenv('NUMPY_INC_DIR')
13+
814
try:
915
# Check if include directory is inside the pandas dir
1016
# e.g. a venv created inside the pandas dir
1117
# If so, convert it to a relative path
12-
incdir = os.path.relpath(np.get_include())
18+
incdir = os.path.relpath(base_incdir)
1319
except Exception:
14-
incdir = np.get_include()
20+
incdir = base_incdir
1521
print(incdir)
1622
''',
1723
],
24+
env: {'NUMPY_INC_DIR': get_option('numpy_inc_dir')},
1825
check: true,
1926
).stdout().strip()
2027

0 commit comments

Comments
 (0)