Skip to content

Document setting limited-api via build option better #624

Closed

Description

@lpsinger

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

Activity

  1. eli-schwartz commented on May 1, 2024

    @eli-schwartz
    Member

    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

  2. rgommers commented on May 1, 2024

    @rgommers
    Contributor

    Yes, we should be handling python.allow_limited_api:

    value = next((option['value'] for option in options if option['name'] == 'python.allow_limited_api'), None)

    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.

  3. lpsinger commented on May 2, 2024

    @lpsinger
    ContributorAuthor

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

  4. changed the title [-]Support setting limited-api via build config settings[/-] [+]Document setting limited-api via build option better[/+] on May 2, 2024
  5. rgommers commented on May 2, 2024

    @rgommers
    Contributor

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

  6. trim21 commented on Nov 27, 2024

    @trim21

    What's the best way to do this currently?

    Enable limited-api pyproject.toml and disable it with --config-settings=setup-args="-Dpython.allow_limited_api=false"?

  7. rgommers commented on Oct 19, 2025

    @rgommers
    Contributor

    I found that this only works one way: defaulting to limited-api=true in pyproject.toml and then opting out via -Csetup-args=-Dpython.allow_limited_api=false works, but one cannot do the reverse and opt into building an abi3 wheel in any way.

    In addition, using limited-api=true in pyproject.toml will not work with free-threaded interpreters, since they don't yet support the limited API (that will only happen in Python 3.15) and hence defaulting to true in pyproject.toml breaks pip install pkgname which is bad. At a minimum, that needs a change like gh-626 to handle this the same way as for PyPy.

    There is more to do though, see gh-793 (and gh-787)

  8. oscarbenjamin commented on Oct 19, 2025

    @oscarbenjamin

    one cannot do the reverse and opt into building an abi3 wheel

    I think I got this working in flintlib/python-flint#326.

    You can set the default for allow_limited_api to false at the top of meson.build:

    project(
      ...
      default_options: ['python.allow_limited_api=false'],
    )
  9. rgommers commented on Oct 19, 2025

    @rgommers
    Contributor

    Thanks @oscarbenjamin 🙏🏼. Agreed it does work (if clumsily). I saw your suggestions in gh-787 after writing my initial comment. Trying that out now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions