Files
cibuildwheel/test/test_projects/meson.py
T
Joe RickerbyandHenry Schreiner a2f965f62f Add an integration test and debug issues with the meson backend (#2718)
* Add an integration test with the meson backend

* Modify script to allow testing of the GHA action on a PR

* Try adding cython to languages in meson config

* Revert "Try adding cython to languages in meson config"

This reverts commit 50378a1c7e38665492ad0c683b178e4d96928e1e.

* Pass --vsenv to meson on windows

As seen here https://github.com/matplotlib/matplotlib/blob/9957c394bd01deb7a9bd9cb27804f447a52dc522/.github/workflows/cibuildwheel.yml#L114

* Disable win32 builds for the meson test

* Move the windows-specific config into the test project definition

This is so it can be tested with bin/run_example_ci_configs.py

* Add some docs to the FAQ about meson on windows

* Update bin/run_example_ci_configs.py

Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>

---------

Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2026-02-08 10:36:47 +00:00

61 lines
1.3 KiB
Python

import jinja2
from .base import TestProject
from .c import SPAM_C_TEMPLATE
PYPROJECT_TOML_TEMPLATE = r"""
[build-system]
requires = ["meson-python"]
build-backend = "mesonpy"
[project]
name = "spam"
version = "0.1.0"
[tool.cibuildwheel.windows]
config-settings = { "setup-args" = "--vsenv" }
# building win32 wheels on a 64-bit CI machine with meson-python
# requires a few extra steps outside cibuildwheel. See
# https://github.com/pypa/cibuildwheel/pull/2718
archs = ["auto64"]
"""
MESON_BUILD_TEMPLATE = r"""
project('spam', 'c',
version: '0.1.0',
default_options: ['warning_level=2'],
)
py = import('python').find_installation(pure: false)
py.extension_module('spam',
'spam.c',
install: true,
)
"""
def new_meson_project(
*,
spam_c_top_level_add: str = "",
spam_c_function_add: str = "",
) -> TestProject:
project = TestProject()
project.files.update(
{
"spam.c": jinja2.Template(SPAM_C_TEMPLATE),
"pyproject.toml": jinja2.Template(PYPROJECT_TOML_TEMPLATE),
"meson.build": jinja2.Template(MESON_BUILD_TEMPLATE),
}
)
project.template_context.update(
{
"spam_c_top_level_add": spam_c_top_level_add,
"spam_c_function_add": spam_c_function_add,
}
)
return project