From 6bac80d9725caf1f69d051a9095bf520891f020e Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Sat, 14 Jun 2025 18:43:04 +0200 Subject: [PATCH 1/6] TST: define minimum required meson version --- tests/packages/limited-api/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/packages/limited-api/meson.build b/tests/packages/limited-api/meson.build index 4973c6f14..606a12242 100644 --- a/tests/packages/limited-api/meson.build +++ b/tests/packages/limited-api/meson.build @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: MIT -project('limited-api', 'c', version: '1.0.0') +project('limited-api', 'c', version: '1.0.0', meson_version: '>= 1.3') py = import('python').find_installation(pure: false) From bbbb78241d8c80c608579f6121a118e47e9a5019 Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Tue, 28 Oct 2025 18:08:44 +0100 Subject: [PATCH 2/6] TST: make test the same with all Meson versions and avoid a warning --- tests/packages/subproject/pyproject.toml | 5 +---- .../packages/subproject/subprojects/dep/meson.build | 13 +++++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/packages/subproject/pyproject.toml b/tests/packages/subproject/pyproject.toml index d339a1bb7..cf1dd4a82 100644 --- a/tests/packages/subproject/pyproject.toml +++ b/tests/packages/subproject/pyproject.toml @@ -8,10 +8,7 @@ requires = ['meson-python'] [tool.meson-python.wheel] exclude = [ - # Meson before version 1.3.0 install data files in - # ``{datadir}/{project name}/``, later versions install - # in the more correct ``{datadir}/{subproject name}/``. - '{datadir}/*/data.txt', + '{datadir}/dep/*.txt', '{py_purelib}/dep.*', ] include = [ diff --git a/tests/packages/subproject/subprojects/dep/meson.build b/tests/packages/subproject/subprojects/dep/meson.build index 34c6b7508..cc7c5c029 100644 --- a/tests/packages/subproject/subprojects/dep/meson.build +++ b/tests/packages/subproject/subprojects/dep/meson.build @@ -6,6 +6,15 @@ project('dep') py = import('python').find_installation() -py.install_sources('dep.py') +py.install_sources( + 'dep.py', +) -install_data('data.txt') +install_data( + 'data.txt', + # Prior to meson 1.3.0, the default install path for subproject data files + # is ``{datadir}/{main-project-name}/``. In later versions it is the more + # correct ``{datadir}/{subproject-name}/``. Specify the install path to + # obtain uniform behavior across different meson versions. + install_dir: '{datadir}' / meson.project_name(), +) From 3acb966308dafaaae1fb620567ce90091d0225c7 Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Sun, 2 Nov 2025 12:12:39 +0100 Subject: [PATCH 3/6] TST: use the same spelling for pytest.mark.skipif() reason --- tests/test_wheel.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_wheel.py b/tests/test_wheel.py index 350798e58..e3c935599 100644 --- a/tests/test_wheel.py +++ b/tests/test_wheel.py @@ -186,7 +186,7 @@ def test_sharedlib_in_package(venv, wheel_sharedlib_in_package): assert int(output) == 42 -@pytest.mark.skipif(MESON_VERSION < (1, 3, 0), reason='Meson version too old') +@pytest.mark.skipif(MESON_VERSION < (1, 3, 0), reason='meson too old') def test_link_library_in_subproject(venv, wheel_link_library_in_subproject): venv.pip('install', wheel_link_library_in_subproject) output = venv.python('-c', 'import foo; print(foo.example_sum(3, 6))') @@ -306,7 +306,7 @@ def test_subprojects(package_subproject, tmp_path): # Requires Meson 1.2.0, see https://github.com/mesonbuild/meson/pull/11909. -@pytest.mark.skipif(MESON_VERSION < (1, 1, 99), reason='Meson version too old') +@pytest.mark.skipif(MESON_VERSION < (1, 1, 99), reason='meson too old') @pytest.mark.parametrize(('arg'), ['--skip-subprojects', '--skip-subprojects=dep']) def test_skip_subprojects(package_subproject, tmp_path, arg): filename = mesonpy.build_wheel(tmp_path, {'install-args': [arg]}) @@ -320,7 +320,7 @@ def test_skip_subprojects(package_subproject, tmp_path, arg): # Requires Meson 1.3.0, see https://github.com/mesonbuild/meson/pull/11745. -@pytest.mark.skipif(MESON_VERSION < (1, 2, 99), reason='Meson version too old') +@pytest.mark.skipif(MESON_VERSION < (1, 2, 99), reason='meson too old') @pytest.mark.skipif(NOGIL_BUILD, reason='Free-threaded CPython does not support the limited API') @pytest.mark.xfail('__pypy__' in sys.builtin_module_names, reason='PyPy does not support the abi3 platform tag for wheels') def test_limited_api(wheel_limited_api): @@ -332,7 +332,7 @@ def test_limited_api(wheel_limited_api): # Requires Meson 1.3.0, see https://github.com/mesonbuild/meson/pull/11745. -@pytest.mark.skipif(MESON_VERSION < (1, 2, 99), reason='Meson version too old') +@pytest.mark.skipif(MESON_VERSION < (1, 2, 99), reason='meson too old') @pytest.mark.skipif(NOGIL_BUILD, reason='Free-threaded CPython does not support the limited API') @pytest.mark.xfail('__pypy__' in sys.builtin_module_names, reason='PyPy does not use special modules suffix for stable ABI') def test_limited_api_bad(package_limited_api, tmp_path): @@ -342,7 +342,7 @@ def test_limited_api_bad(package_limited_api, tmp_path): # Requires Meson 1.3.0, see https://github.com/mesonbuild/meson/pull/11745. -@pytest.mark.skipif(MESON_VERSION < (1, 2, 99), reason='Meson version too old') +@pytest.mark.skipif(MESON_VERSION < (1, 2, 99), reason='meson too old') def test_limited_api_disabled(package_limited_api, tmp_path): filename = mesonpy.build_wheel(tmp_path, {'setup-args': ['-Dpython.allow_limited_api=false']}) artifact = wheel.wheelfile.WheelFile(tmp_path / filename) @@ -401,7 +401,7 @@ def test_custom_target_install_dir(package_custom_target_dir, tmp_path): } # On Linux, Meson 1.10 or later is required, see https://github.com/mesonbuild/meson/pull/15141 -@pytest.mark.skipif(sys.platform == 'linux' and MESON_VERSION < (1, 9, 99), reason='Meson version too old') +@pytest.mark.skipif(sys.platform == 'linux' and MESON_VERSION < (1, 9, 99), reason='meson too old') @pytest.mark.skipif(sys.platform not in {'linux', 'darwin'}, reason='Not supported on this platform') def test_cmake_subproject(wheel_cmake_subproject): artifact = wheel.wheelfile.WheelFile(wheel_cmake_subproject) From d0ee92e5ce6bf9efcd9f36182bd23c43f1a6fc31 Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Sun, 2 Nov 2025 13:59:57 +0100 Subject: [PATCH 4/6] MAINT: make mypy happy not redefining a variable to a different type --- mesonpy/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesonpy/__init__.py b/mesonpy/__init__.py index 77b0be327..aaddde316 100644 --- a/mesonpy/__init__.py +++ b/mesonpy/__init__.py @@ -838,8 +838,8 @@ def __init__( if self._limited_api: # check whether limited API is disabled for the Meson project options = self._info('intro-buildoptions') - value = next((option['value'] for option in options if option['name'] == 'python.allow_limited_api'), None) - if not value: + allow_limited_api = next((opt['value'] for opt in options if opt['name'] == 'python.allow_limited_api'), None) + if not allow_limited_api: self._limited_api = False if self._limited_api and bool(sysconfig.get_config_var('Py_GIL_DISABLED')): From cfbe556005b449b805352e9d021704ef3ee3b7a0 Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Sun, 2 Nov 2025 13:03:02 +0100 Subject: [PATCH 5/6] TST: enable fatal meson warnings for almost all test packages This uses a pytest ``autouse`` fixture to monkeypatch the function that validates the ``pyproject.toml`` meson-python configuration to add ``--fatal-meson-warnings`` to the ``meson setup`` arguments, unless ``--no-fatal-meson-warnings`` is specified by the package. --- tests/conftest.py | 30 ++++++++++++++++++++++++++++++ tests/test_project.py | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index af737968c..919a57c75 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -192,3 +192,33 @@ def cleanenv(): # $MACOSX_DEPLOYMENT_TARGET affects the computation of the platform tag on macOS. yield mpatch.delenv('MACOSX_DEPLOYMENT_TARGET', raising=False) mpatch.undo() + + +@pytest.fixture(autouse=True, scope='session') +def meson_fatal_warnings(): + # Cannot use the 'monkeypatch' fixture because of scope mismatch. + mpatch = pytest.MonkeyPatch() + mesonpy_project_init = mesonpy.Project.__init__ + + def __init__(self, source_dir, build_dir, meson_args=None, editable_verbose=False): + if pathlib.Path(source_dir).absolute().name not in { + + # The CMake subproject emits ``WARNING: CMake Toolchain: + # Failed to determine CMake compilers state`` on some + # systems. This is probably related to missing Rust or ObjC + # toolchains. + 'cmake-subproject', + + # The ``link-against-local-lib`` package uses linker arguments + # to add RPATH entries. This functionality is deprecated in + # Meson but it is used in the wild thus we should make sure it + # keeps working. + 'link-against-local-lib', + + }: + if meson_args is None: + meson_args = {} + meson_args.setdefault('setup', []).append('--fatal-meson-warnings') + mesonpy_project_init(self, source_dir, build_dir, meson_args, editable_verbose) + + mpatch.setattr(mesonpy.Project, '__init__', __init__) diff --git a/tests/test_project.py b/tests/test_project.py index 11b229ab7..b511b2171 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -399,7 +399,7 @@ def test_ios_project(package_simple, monkeypatch, multiarch, tmp_path): project = mesonpy.Project(source_dir=package_simple, build_dir=tmp_path) # Meson configuration points at the cross file - assert project._meson_args['setup'] == ['--cross-file', os.fspath(tmp_path / 'meson-python-cross-file.ini')] + assert project._meson_args['setup'][-2:] == ['--cross-file', os.fspath(tmp_path / 'meson-python-cross-file.ini')] # Meson config files exist, and have some relevant keys assert (tmp_path / 'meson-python-native-file.ini').exists() From 97b08a3ceebd933c780b53ff70afb83a5da8d059 Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Wed, 19 Nov 2025 00:03:50 +0100 Subject: [PATCH 6/6] CI: update from macOs 13 to to macOS 15 on intel macOS 13 is being discontinued. --- .github/workflows/tests.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0b96d31ea..057c35b64 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -41,12 +41,10 @@ jobs: matrix: os: - ubuntu-latest - # actions/setup-python do not support Python 3.7 on macOS on - # arm64. The latest macOS version available is macOS 14 but - # it is arm64 only. Stick to macos-13 as long as we want to - # test Python 3.7 on macOS. macOS 14 on arm64 is covered by - # the Cirrus CI jobs. - - macos-13 + # macOS 14 on arm64 is covered by the Cirrus CI jobs, stick to macOS + # on x86-64 here as long as we can: macOS 15 is currently planned as + # the last supported image based on Intel CPU on GitHub Actions. + - macos-15-intel - windows-latest python: - '3.9'