Skip to content

Commit 08db644

Browse files
committed
PEP 803: Add abi3t filename tag
1 parent 63c2676 commit 08db644

File tree

1 file changed

+45
-11
lines changed

1 file changed

+45
-11
lines changed

peps/pep-0803.rst

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,20 @@ The tag ``abi3t`` is chosen to reflect the fact that this ABI is similar to
288288
uses the letter ``t`` in existing, version-specific ABI tags like ``cp314t``).
289289

290290

291+
Filename tag
292+
------------
293+
294+
On systems that use the ``abi3`` tag in filenames, a new filename tag
295+
(``abi3t``) is added so that older stable ABI extensions
296+
(:samp:`{name}.abi3.so`) can be installed in the same directory as ones that
297+
support Stable ABI for free-threaded Python (:samp:`{name}.abi3t.so`).
298+
299+
There can only be one ABI tag in a filename (there is no concept of "compressed
300+
tag sets like in wheel tags), so extensions that are compatible with both ABIs
301+
at once need to use *one* of the tags -- the new one (``abi3t``), which
302+
is currently unused.
303+
304+
291305
Specification
292306
=============
293307

@@ -461,14 +475,34 @@ and may be removed in future CPython versions,
461475
if the internal object layout needs to change.
462476

463477

464-
The ``abi3t`` wheel tag
465-
-----------------------
478+
The ``abi3t`` wheel and filename tags
479+
-------------------------------------
466480

467481
Wheels that use a stable ABI compatible with free-threading CPython builds
468482
should use a new `ABI tag`_: ``abi3t``.
469483

470484
.. _ABI tag: https://packaging.python.org/en/latest/specifications/platform-compatibility-tags/#abi-tag
471485

486+
On systems where filenames of Stable ABI extensions end with ``.abi3.so``,
487+
extensions that support free-threading should instead use ``abi3t.so``.
488+
This includes extensions compatible with *both* ``abi3`` and ``abi3t``.
489+
490+
On these systems, all builds of CPython -- GIL-enabled and free-threaded --
491+
will load extensions with the ``abi3t`` tag.
492+
Free-threaded builds will -- unlike in 3.14 -- *not* load extensions
493+
with the ``abi3`` tag.
494+
If files are present with both tags, GIL-enabled builds will prefer
495+
"their" ``*.abi3.so`` over ``*.abi3t.so``.
496+
497+
Put another way, ``importlib.machinery.EXTENSION_SUFFIXES`` will be
498+
(for ``x86_64-linux-gnu`` builds of CPython):
499+
500+
* ``python3.15``:
501+
``['.cpython-315-x86_64-linux-gnu.so', '.abi3.so', '.abi3t.so', '.so']``
502+
* ``python3.15t``:
503+
``['.cpython-315-x86_64-linux-gnu.so', '.abi3t.so', '.so']``
504+
505+
472506
Recommendations for installers
473507
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
474508

@@ -504,6 +538,13 @@ In the above, :samp:`{v}` stands for a the lowest Python version with which
504538
the extension should be compatible, in :c:func:`Py_PACK_VERSION` format.
505539
In the cases above, this version must be set to 3.15 or higher.
506540

541+
In both cases, if a resulting extension's *filename* would use the ``abi3``
542+
tag (that is, :samp:`{modulename}.abi3.so` on Linux, macOS, and similar),
543+
the ``abi3t`` tag should be used instead (that is,
544+
:samp:`{modulename}.abi3t.so` on those systems).
545+
If this tag is not used, there should be no change. (This is always the case
546+
on Windows, where the filename should remain :samp:`{name}.pyd`.)
547+
507548
.. _compressed tag set: https://packaging.python.org/en/latest/specifications/platform-compatibility-tags/#compressed-tag-sets
508549

509550
The version of the Stable ABI, both ``abi3`` and ``abi3t``, is indicated by
@@ -783,15 +824,8 @@ Naming this ``abi4``
783824
Instead of ``abi3t``, we could “bump the version” and use ``abi4`` instead.
784825
The difference is largely cosmetic.
785826

786-
However, one thing this PEP does not propose is changing the *filename*
787-
tag: extensions will be named with the extensions like ``.abi3.so``.
788-
Changing this while keeping compatibility with GIL-enabled builds would be
789-
an unnecessary technical change.
790-
791-
Using ``abi3.abi4`` in wheel tags but only ``.abi3`` in filenames would
792-
look more inconsistent than ``abi3.abi3t`` and ``.abi3``.
793-
794-
If we added an ``abi4`` tag, the ``Py_LIMITED_API`` value would either need to:
827+
If we added an ``abi4`` tag, the value of the opt-in macro (``Py_TARGET_ABI4``
828+
or ``Py_LIMITED_API`` or some such) would either need to:
795829

796830
* change to start with ``4`` to match ``abi4``, but no longer correspond
797831
to ``PY_VERSION_HEX`` (making it harder to generate and check), or

0 commit comments

Comments
 (0)