Repository navigation
Add sys.abi_info to make information about the interpreter ABI more accessible #133143
Copy link
Copy link
Closed
Closed
Copy link
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-featureA feature request or enhancementA feature request or enhancement
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancement
on Apr 29, 2025 Hello, I think this discussion should happen on the forums to get better visibility from the core devs.
Thanks for your feedback, @merwok. As you can see from the description, there have been a few discussions on the forum already; this is an effort to drive things closer to implementation.
I hope that makes sense?
Sure, but few Python core devs read all the packaging threads, so discuss is still the place to discuss changes like this before implementing.
- addedextension-modulesC modules in the Modules dirC modules in the Modules dir
on May 1, 2025 Hello, I think this discussion should happen on the forums to get better visibility from the core devs.
- added a commit that references this issue
on Sep 8, 2025 I noticed a possible small refactoring
sysmodule.c(for a follow-up PR because it will also touch some existing code):- Instead of
PyUnicode_FromString("...")(with a literal string), use&_Py_ID(...)(a static immortal constant; note that there are no quotes)- some of these are behind the
SET_SYS_FROM_STRINGmacro
- some of these are behind the
- Run
make regen-global-objectsto generate code for new_Py_IDs
- Instead of
- changed the title
[-]Add `sys.abi_features` to make information about the interpreter ABI more accessible[/-][+]Add `sys.abi_info` to make information about the interpreter ABI more accessible[/+]on Nov 5, 2025
Metadata
Metadata
Assignees
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-featureA feature request or enhancementA feature request or enhancement
Feature or enhancement
Proposal:
Early on in the discussion of PEP 780: ABI features as environment markers a certain shortcoming of ABI information availability was identified and discussed.
One suggestion was to adopt a new mechanism for making this kind of information available, which initially was included as a proposal in PEP 780 itself. However, that PEP is aimed at improving the packaging situation and to improve that focus, the addition to the standard library is no longer part of it.
Here, we propose to add ABI information to the standard library in the form of a new attribute to the
sysmodule.In PEP 780 three ABI features are identified, namely
free-threadingorgil-enabled(only CPython)If the Python interpreter is free-threaded, the
free-threadingfeature MUST be present and thegil-enabledfeature MUST NOT be present. Otherwise, thegil-enabledfeature MUST be present and thefree-threadingfeature MUST NOT be present.debug(only CPython, optional)This ABI feature is reserved for the
--with-pydebugbuild of CPython. If the interpreter is a CPython interpreter withPy_DEBUGcapabilities, thedebugfeature MUST be present. On POSIX systems, this corresponds to the Python expression"d" in sys.abiflags.32-bitor64-bit(optional)The bitness of the interpreter, that is, whether it is a 32-bit or 64-bit build. If the bitness is unknown or neither 32-bit nor 64-bit, this feature MUST NOT be present.
A reference implementation of this feature is available, which adds these features as a frozen set of identifying strings to
sys.abi_features.For purposes of the environment markers defined in PEP 780, only the presence or absence of the features is relevant. However, in the discussion of the reference implementation @FFY00 suggested that a more comprehensive implementation might be useful, for example providing additional information about the ABI features, such as their representation in
sys.abiflags(which directly impacts their possible representation in the ABI tags used for wheels and extension modules), or their default state.This addition to the standard library will make crucial ABI information much easier to access.
We think this fully backwards compatible addition can be made with a simple pull request.
It would be great to hear from the CPython team.
Do you agree that this is a useful feature?
Do you think detailed information beyond simple presence or absence of ABI features should be included?
Do you have suggestions for the exact API?
Has this already been discussed elsewhere?
I have already discussed this feature proposal on Discourse
Links to previous discussion of this feature:
Initial thoughts on this feature, have surfaced in the discussions leading to PEP 780.
During the discussion of the PEP, further comments were made, leading to the separation from the PEP with further review comments available.
Linked PRs
sys.abi_info#138672