Files
cibuildwheel/test/test_projects/meson.py
T
1cf64d0d3c feat: Android improvements needed for building NumPy and related packages (#2695)
* Use auditwheel on Android

* Add auditwheel command to defaults

* pkgconfig fixes

* Pre-import ctypes before monkey-patching in _cross_venv

* Set PKG_CONFIG and PKG_CONFIG_RELOCATE_PATHS variables

* Initial attempt at using mzakharo/android-gfortran

* Switch to using termux/ndk-toolchain-clang-with-flang

* Move PKG_CONFIG variables from build_env to android_env

* Simplify flang installation

* Add cross build files for NumPy

* Add ldpaths entry for libomp

* Add `--rm` to docker command line

* Make Rust and Fortran shims consistent

* Update documentation

* Default to API level 24 on all Python versions

* Clarify comments

* Cleanups

* Fix tests:
* Set up Android env after installing pkgconf
* Add tests for successfully using an older API level
* Previous commit's auditwheel failure is fixed in the auditwheel PR

* Update how-it-works diagram

* Add tests for repair errors

* Add more repair tests

* Add test for Meson and Fortran

* Add test for cross build files

* Improve test_api_level error message

* Add xbuild-files option

* use pypa/auditwheel@main

* Remove dependencies which are no longer needed

* Fix README

* Update to auditwheel 6.7.0

* Fix compatibility with pkgconf 2.5.1.post2

* Documentation clarifications

Co-authored-by: Joe Rickerby <joerick@mac.com>

* Fortran shim improvements

* Add Jinja variables to new_meson_project

* Update run_example_ci_configs for changed new_meson_project signature

* Add missing dependency to run_example_ci_configs

---------

Co-authored-by: mayeut <mayeut@users.noreply.github.com>
Co-authored-by: Joe Rickerby <joerick@mac.com>
2026-05-29 00:27:28 -04:00

67 lines
1.5 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',
{{ project_args_add | indent(2) }}
version: '0.1.0',
default_options: ['warning_level=2'],
)
py = import('python').find_installation(pure: false)
py.extension_module('spam',
'spam.c',
{{ extension_args_add | indent(2) }}
install: true,
)
"""
def new_meson_project(
*,
spam_c_top_level_add: str = "",
spam_c_function_add: str = "",
project_args_add: str = "",
extension_args_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,
"project_args_add": project_args_add,
"extension_args_add": extension_args_add,
}
)
return project