Skip to content

Commit 88f435c

Browse files
committed
Move NumPy include to prevent "import json" collision
1 parent 82ac165 commit 88f435c

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

python/meson.build

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,39 @@ arrow_dep = dependency(
4343
required: false,
4444
)
4545

46+
# When NumPy 2.0 becomes the minimum we can remove the
47+
# custom location check
48+
numpy_dep = dependency('numpy', required: false)
49+
if not numpy_dep.found()
50+
cmd = run_command(
51+
py,
52+
[
53+
'-c',
54+
'''import os
55+
import numpy as np
56+
try:
57+
# Check if include directory is inside the pyarrow dir
58+
# e.g. a venv created inside the pyarrow dir
59+
# If so, convert it to a relative path
60+
incdir = os.path.relpath(np.get_include())
61+
except Exception:
62+
incdir = np.get_include()
63+
print(incdir)
64+
''',
65+
],
66+
check: false,
67+
)
68+
69+
if cmd.returncode() != 0
70+
message(cmd.stdout())
71+
message(cmd.stderr())
72+
error('Failure with NumPy command')
73+
endif
74+
numpy_inc = cmd.stdout().strip()
75+
76+
numpy_dep = declare_dependency(include_directories: incdir_numpy)
77+
endif
78+
4679
cc = meson.get_compiler('cpp')
4780

4881
subdir('pyarrow')

python/pyarrow/meson.build

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,6 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
# When NumPy 2.0 becomes the minimum we can remove the
19-
# custom location check
20-
numpy_dep = dependency('numpy', required: false)
21-
if not numpy_dep.found()
22-
cmd = run_command(
23-
py,
24-
[
25-
'-c',
26-
'''import os
27-
import numpy as np
28-
try:
29-
# Check if include directory is inside the pyarrow dir
30-
# e.g. a venv created inside the pyarrow dir
31-
# If so, convert it to a relative path
32-
incdir = os.path.relpath(np.get_include())
33-
except Exception:
34-
incdir = np.get_include()
35-
print(incdir)
36-
''',
37-
],
38-
check: false,
39-
)
40-
41-
if cmd.returncode() != 0
42-
message(cmd.stdout())
43-
message(cmd.stderr())
44-
error('Failure with NumPy command')
45-
endif
46-
numpy_inc = cmd.stdout().strip()
47-
48-
numpy_dep = declare_dependency(include_directories: incdir_numpy)
49-
endif
50-
5118
cython_args = ['--include-dir', meson.current_source_dir()]
5219
if get_option('buildtype') in ['debug', 'debugoptimized']
5320
cython_args += ['--gdb']

0 commit comments

Comments
 (0)