Skip to content

Commit 7ae516a

Browse files
rgommersmroeschke
authored andcommitted
BLD: improvements to meson.build files (pandas-dev#54949)
* BLD: some changes to make meson.build more idiomatic - Use `pure: false` only in a single place. This is recommended for robustness, this way you can't forget it in a subdirectory and end up with a subtly broken package only on niche Linux distros that split purelib and platlib directories. - Use `py.install_sources` with a list input rather than in a foreach loop. - Remove the `werror` comment: it's never a good idea to enable `-Werror` by default in the build config of a library, that can easily break builds. This should be done in one or more CI jobs instead. * BLD: run `generate_version.py` with a shebang, not 'python' The way this was before can result in build failures. It assumed that `python` is a working Python 3.x interpreter, and that is not always true. See for example this bug report for the exact same thing in NumPy, where `python` isn't working for Sage: numpy/numpy#24514 Meson guarantees that .py scripts with a shebang on the top line will be run with a Python interpreter (if there's none on the PATH, it can use the one Meson itself is run with). Hence this is the most robust way of using `run_command` on a .py script.
1 parent 836e7fe commit 7ae516a

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

generate_version.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env python3
2+
13
# Note: This file has to live next to setup.py or versioneer will not work
24
import argparse
35
import os

meson.build

+9-7
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22
project(
33
'pandas',
44
'c', 'cpp', 'cython',
5-
version: run_command(['python', 'generate_version.py', '--print'], check: true).stdout().strip(),
5+
version: run_command(['generate_version.py', '--print'], check: true).stdout().strip(),
66
license: 'BSD-3',
77
meson_version: '>=1.0.1',
88
default_options: [
99
'buildtype=release',
10-
# TODO: Reactivate werror, some warnings on Windows
11-
#'werror=true',
1210
'c_std=c99'
1311
]
1412
)
1513

1614
fs = import('fs')
17-
py = import('python').find_installation()
15+
py = import('python').find_installation(pure: false)
1816
tempita = files('generate_pxi.py')
1917
versioneer = files('generate_version.py')
2018

@@ -30,7 +28,7 @@ add_project_arguments('-DNPY_TARGET_VERSION=NPY_1_21_API_VERSION', language : 'c
3028

3129

3230
if fs.exists('_version_meson.py')
33-
py.install_sources('_version_meson.py', pure: false, subdir: 'pandas')
31+
py.install_sources('_version_meson.py', subdir: 'pandas')
3432
else
3533
custom_target('write_version_file',
3634
output: '_version_meson.py',
@@ -40,11 +38,15 @@ else
4038
build_by_default: true,
4139
build_always_stale: true,
4240
install: true,
43-
install_dir: py.get_install_dir(pure: false) / 'pandas'
41+
install_dir: py.get_install_dir() / 'pandas'
4442
)
4543
meson.add_dist_script(py, versioneer, '-o', '_version_meson.py')
4644
endif
4745

4846
# Needed by pandas.test() when it looks for the pytest ini options
49-
py.install_sources('pyproject.toml', pure: false, subdir: 'pandas')
47+
py.install_sources(
48+
'pyproject.toml',
49+
subdir: 'pandas'
50+
)
51+
5052
subdir('pandas')

pandas/_libs/meson.build

+4-3
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,9 @@ foreach ext_name, ext_dict : libs_sources
114114
)
115115
endforeach
116116

117-
py.install_sources('__init__.py',
118-
pure: false,
119-
subdir: 'pandas/_libs')
117+
py.install_sources(
118+
'__init__.py',
119+
subdir: 'pandas/_libs'
120+
)
120121

121122
subdir('window')

pandas/_libs/tslibs/meson.build

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ foreach ext_name, ext_dict : tslibs_sources
3131
)
3232
endforeach
3333

34-
py.install_sources('__init__.py',
35-
pure: false,
36-
subdir: 'pandas/_libs/tslibs')
34+
py.install_sources(
35+
'__init__.py',
36+
subdir: 'pandas/_libs/tslibs'
37+
)

pandas/meson.build

+3-6
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,14 @@ subdirs_list = [
4040
'util'
4141
]
4242
foreach subdir: subdirs_list
43-
install_subdir(subdir, install_dir: py.get_install_dir(pure: false) / 'pandas')
43+
install_subdir(subdir, install_dir: py.get_install_dir() / 'pandas')
4444
endforeach
45+
4546
top_level_py_list = [
4647
'__init__.py',
4748
'_typing.py',
4849
'_version.py',
4950
'conftest.py',
5051
'testing.py'
5152
]
52-
foreach file: top_level_py_list
53-
py.install_sources(file,
54-
pure: false,
55-
subdir: 'pandas')
56-
endforeach
53+
py.install_sources(top_level_py_list, subdir: 'pandas')

0 commit comments

Comments
 (0)