Description
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 sys
module.
In PEP 780 three ABI features are identified, namely
-
free-threading
orgil-enabled
(only CPython)
If the Python interpreter is free-threaded, thefree-threading
feature MUST be present and thegil-enabled
feature MUST NOT be present. Otherwise, thegil-enabled
feature MUST be present and thefree-threading
feature MUST NOT be present. -
debug
(only CPython, optional)
This ABI feature is reserved for the--with-pydebug
build of CPython. If the interpreter is a CPython interpreter withPy_DEBUG
capabilities, thedebug
feature MUST be present. On POSIX systems, this corresponds to the Python expression"d" in sys.abiflags
. -
32-bit
or64-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.