From 8d45999b9e131b54abe2b8782ae6d4df3c649afa Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Sat, 2 Sep 2023 11:39:36 +0200 Subject: [PATCH 1/2] 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. --- meson.build | 14 ++++++++------ pandas/_libs/meson.build | 7 ++++--- pandas/_libs/tslibs/meson.build | 7 ++++--- pandas/meson.build | 9 +++------ 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/meson.build b/meson.build index 09a1494135af4..b71bf4372706c 100644 --- a/meson.build +++ b/meson.build @@ -7,14 +7,12 @@ project( meson_version: '>=1.0.1', default_options: [ 'buildtype=release', - # TODO: Reactivate werror, some warnings on Windows - #'werror=true', 'c_std=c99' ] ) fs = import('fs') -py = import('python').find_installation() +py = import('python').find_installation(pure: false) tempita = files('generate_pxi.py') versioneer = files('generate_version.py') @@ -30,7 +28,7 @@ add_project_arguments('-DNPY_TARGET_VERSION=NPY_1_21_API_VERSION', language : 'c if fs.exists('_version_meson.py') - py.install_sources('_version_meson.py', pure: false, subdir: 'pandas') + py.install_sources('_version_meson.py', subdir: 'pandas') else custom_target('write_version_file', output: '_version_meson.py', @@ -40,11 +38,15 @@ else build_by_default: true, build_always_stale: true, install: true, - install_dir: py.get_install_dir(pure: false) / 'pandas' + install_dir: py.get_install_dir() / 'pandas' ) meson.add_dist_script(py, versioneer, '-o', '_version_meson.py') endif # Needed by pandas.test() when it looks for the pytest ini options -py.install_sources('pyproject.toml', pure: false, subdir: 'pandas') +py.install_sources( + 'pyproject.toml', + subdir: 'pandas' +) + subdir('pandas') diff --git a/pandas/_libs/meson.build b/pandas/_libs/meson.build index f302c649bc7bd..1126eca4bde9e 100644 --- a/pandas/_libs/meson.build +++ b/pandas/_libs/meson.build @@ -113,8 +113,9 @@ foreach ext_name, ext_dict : libs_sources ) endforeach -py.install_sources('__init__.py', - pure: false, - subdir: 'pandas/_libs') +py.install_sources( + '__init__.py', + subdir: 'pandas/_libs' +) subdir('window') diff --git a/pandas/_libs/tslibs/meson.build b/pandas/_libs/tslibs/meson.build index 14d2eef46da20..167695b84514c 100644 --- a/pandas/_libs/tslibs/meson.build +++ b/pandas/_libs/tslibs/meson.build @@ -31,6 +31,7 @@ foreach ext_name, ext_dict : tslibs_sources ) endforeach -py.install_sources('__init__.py', - pure: false, - subdir: 'pandas/_libs/tslibs') +py.install_sources( + '__init__.py', + subdir: 'pandas/_libs/tslibs' +) diff --git a/pandas/meson.build b/pandas/meson.build index 1dc9955aa4ff6..f02258c98d46a 100644 --- a/pandas/meson.build +++ b/pandas/meson.build @@ -40,8 +40,9 @@ subdirs_list = [ 'util' ] foreach subdir: subdirs_list - install_subdir(subdir, install_dir: py.get_install_dir(pure: false) / 'pandas') + install_subdir(subdir, install_dir: py.get_install_dir() / 'pandas') endforeach + top_level_py_list = [ '__init__.py', '_typing.py', @@ -49,8 +50,4 @@ top_level_py_list = [ 'conftest.py', 'testing.py' ] -foreach file: top_level_py_list - py.install_sources(file, - pure: false, - subdir: 'pandas') -endforeach +py.install_sources(top_level_py_list, subdir: 'pandas') From e0b7fb7c4b1125142f44f08292b171eaab7ffc6b Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Sat, 2 Sep 2023 11:49:53 +0200 Subject: [PATCH 2/2] 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: https://github.com/numpy/numpy/issues/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. --- generate_version.py | 2 ++ meson.build | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/generate_version.py b/generate_version.py index 46e9f52bfc5de..06e38ce0fd978 100644 --- a/generate_version.py +++ b/generate_version.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + # Note: This file has to live next to setup.py or versioneer will not work import argparse import os diff --git a/meson.build b/meson.build index b71bf4372706c..e0e533ffade97 100644 --- a/meson.build +++ b/meson.build @@ -2,7 +2,7 @@ project( 'pandas', 'c', 'cpp', 'cython', - version: run_command(['python', 'generate_version.py', '--print'], check: true).stdout().strip(), + version: run_command(['generate_version.py', '--print'], check: true).stdout().strip(), license: 'BSD-3', meson_version: '>=1.0.1', default_options: [