Skip to content

Support for Python limited API extensions assumes there is only one valid extension suffix #15637

@ngoldbaum

Description

@ngoldbaum

I am working on ecosystem support for the free-threaded build of Python. Lately I've been thinking about PEP 803, which proposes a new version of the stable ABI that can support the free-threaded build.

Yesterday, while working on a test to validate the possibility of distributing .abi3t.so extensions that are loadable on both builds, I realized that currently Meson hard-codes the index into importlib.machinery.EXTENSION_SUFFIXES to find the suffix to use at build time:

limited_api_suffix = None
if sys.version_info >= (3, 2):
try:
from importlib.machinery import EXTENSION_SUFFIXES
limited_api_suffix = EXTENSION_SUFFIXES[1]
except Exception:
pass

For reference, on my Mac:

goldbaum at Nathans-MBP in ~
○  python
Python 3.14.3 free-threading build (main, Feb 10 2026, 08:41:08) [Clang 17.0.0 (clang-1700.6.3.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import importlib.machinery
>>> importlib.machinery.EXTENSION_SUFFIXES
['.cpython-314t-darwin.so', '.abi3.so', '.so']

Even if PEP 803 doesn't go into CPython for the 3.15 release cycle, IMO it's still worth adding some way for a user to supply the extension name and override that, but still verify that the provided extension suffix is present in the EXTENSION_SUFFIXES list provided by the interpreter. This also has bearing on other proposals from Debian to modify this list: python/cpython#122917. I'm not sure offhand if Debian carries a patch for this.

Once there's a UI in meson, then meson-python can be updated to select the correct extension name depending on the project's build configuration.

Ping @mgorny who I chatted with a little about this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions