mesonbuild / meson-python

Meson PEP 517 Python build backend
https://mesonbuild.com/meson-python/
MIT License
118 stars 59 forks source link

Document setting limited-api via build option better #624

Open lpsinger opened 2 months ago

lpsinger commented 2 months ago

The limited-api option can only be set through pyproject.toml, not through the build config settings that you can provide on the command line to pip or python -m build.

Would you please consider supporting limited-api as a build config setting? I am using cibuildwheel to build a package that uses the limited API, but my build fails when it tries to install the build package and run my tests under pypy with the following error:

  ERROR: hpx-0.0.1-pp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl is not a supported wheel on this platform.

I would like to be able to customize the build so that it sets limited-api to false for PyPy, but I can't do this because limited-api is not a build config setting. Here's what I would like to do:

[tool.cibuildwheel]
config-settings.limited-api = true

# PyPy does not support the Python limited API.
[[tool.cibuildwheel.overrides]]
select = "pp*"
config-settings.limited-api = false
eli-schwartz commented 2 months ago

build config settings, as in the kind that are compatible with pip install --config-settings="....", take the form:

--config-settings=setup-args="-Dpython.allow_limited_api=true"

as documented by https://mesonbuild.com/Builtin-options.html#module-options

rgommers commented 2 months ago

Yes, we should be handling python.allow_limited_api: https://github.com/mesonbuild/meson-python/blob/6c728bd047372ea9ad7427851d5fc414159bb4a6/mesonpy/__init__.py#L758

And we just added a more descriptive error a few lines below that (not in the 0.16.0 release yet), but only for free-threaded CPython and not PyPy.

Guess we should improve the error message and the docs a bit more.

lpsinger commented 1 month ago

Yes, this worked, although somehow I found it hard to find this in the documentation.

rgommers commented 1 month ago

Great, thanks for confirming. Changed the issue title to reflect that we need to improve the docs here.