@@ -16,7 +16,7 @@ Abstract
1616========
1717
1818Add a new variant of the Stable ABI, called “Stable ABI for Free-Threaded
19- Python” (or ``abi3t `` for short), and a corresponding API limitations .
19+ Python” (or ``abi3t `` for short).
2020
2121``abi3t `` will be based on the existing Stable ABI (``abi3 ``), but make the
2222:c:type: `PyObject ` structure opaque.
@@ -288,20 +288,6 @@ The tag ``abi3t`` is chosen to reflect the fact that this ABI is similar to
288288uses 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-
305291Specification
306292=============
307293
@@ -484,29 +470,27 @@ should use a new `ABI tag`_: ``abi3t``.
484470.. _ABI tag : https://packaging.python.org/en/latest/specifications/platform-compatibility-tags/#abi-tag
485471
486472On 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 ``:
473+ extensions compatible with ``abi3t `` should instead use ``.abi3t.so ``.
474+ Extensions compatible with *both * ``abi3 `` and ``abi3t `` should not use
475+ a tag; they sould end in ``.so `` only.
476+
477+ On these systems, free-threaded builds of CPython will load extensions
478+ with the ``abi3t `` tag.
479+
480+ For example, for ``x86_64-linux-gnu `` builds of CPython,
481+ ``importlib.machinery.EXTENSION_SUFFIXES `` will be:
482+
483+ * for ``python3.15 ``:
484+ ``['.cpython-315-x86_64-linux-gnu.so', '.abi3.so', '.so'] ``
485+ * for ``python3.15t ``:
503486 ``['.cpython-315-x86_64-linux-gnu.so', '.abi3t.so', '.so'] ``
504487
505488
506489Recommendations for installers
507490^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
508491
509- Package installers should treat this tag as completely separate from ``abi3 ``.
492+ Package installers should treat the ``abi3t `` tag as completely separate
493+ from ``abi3 ``.
510494They should allow ``abi3t ``-tagged wheels for free-threaded builds wherever
511495they currently allow ``abi3 ``-tagged ones for (otherwise equal)
512496non-free-threaded builds.
@@ -526,25 +510,29 @@ Stable ABI (``abi3``):
526510 - defining ``Py_GIL_DISABLED `` (on Windows)
527511 - building with free-threaded CPython headers (elsewhere)
528512
529- Such extensions should be tagged with the `compressed tag set `_
530- ``abi3.abi3t ``.
513+ The filename of the resulting extension should not have a :pep: `3149 `
514+ tag: it should be named :samp: `{ modulename } .so `, :samp: `{ modulename } .pyd `
515+ or similar.
516+
517+ Wheels with such extensions should be tagged with the
518+ `compressed tag set `_ ``abi3.abi3t ``.
531519
532520- Compile extensions compatible with *only * ``abi3t ``, by defining only
533521 :samp: `Py_TARGET_ABI3T={ v } ` and tagging the result with ``abi3t ``.
534522 This will initially offer no advantages over the ``abi3.abi3t `` option
535523 above, but there is a possibility that it will become useful in the future.
536524
525+ On systems that use the :pep: `3149 ` tag ``abi3 `` tag (e.g. on Linux, macOS,
526+ and similar, which use :samp: `{ modulename } .abi3.so `),
527+ such extensions should use the tag ``abi3t `` (that is, the extension should
528+ be named :samp: `{ modulename } .abi3t.so ` on those systems).
529+
530+ Wheels with such extensions should be tagged with the ABI tag ``abi3t ``.
531+
537532In the above, :samp: `{ v } ` stands for a the lowest Python version with which
538533the extension should be compatible, in :c:func: `Py_PACK_VERSION ` format.
539534In the cases above, this version must be set to 3.15 or higher.
540535
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-
548536.. _compressed tag set : https://packaging.python.org/en/latest/specifications/platform-compatibility-tags/#compressed-tag-sets
549537
550538The version of the Stable ABI, both ``abi3 `` and ``abi3t ``, is indicated by
@@ -685,7 +673,7 @@ free-threaded one.
685673(*): Wheels with these tags cannot be built; see table below
686674
687675The following table summarizes which wheel tag should be used for an extension
688- built with a given interpreter and `` Py_LIMITED_API `` macro :
676+ built with the given interpreter and defined macros :
689677
690678+-----------------------+-------------+--------------------+---------------------+-----------+
691679| To get the wheel tag… | Compile on… | ``Py_LIMITED_API `` | ``Py_TARGET_ABI3T `` | Note |
@@ -761,7 +749,8 @@ This PEP combines several pieces, implemented individually:
761749 `python/cpython#137212 <https://github.com/python/cpython/pull/137212 >`__.
762750- A check for older ``abi3 `` was implemented in GitHub pull request
763751 `python/cpython#137957 <https://github.com/python/cpython/pull/137957 >`__.
764- - For wheel tags, there is no implementation yet.
752+ - For wheel tags, a draft pull request is at
753+ `pypa/packaging/pull#1099 <https://github.com/pypa/packaging/pull/1099 >`__.
765754- A porting guide is not yet written.
766755
767756
@@ -836,6 +825,24 @@ better as a transitional state before larger changes like :pep:`809`'s
836825``abi2026 ``.
837826
838827
828+ ``abi3+abi3t `` filename tag
829+ ---------------------------
830+
831+ Extensions that are compatible with both ``abi3 `` and ``abi3t `` can
832+ use a "compressed tag set" (``abi3.abi3t ``) in wheel metadata,
833+ but not in filenames (``.abi3.so ``/``.abi3t.so ``).
834+
835+ We could add a dedicated tag for the combination -- for example,
836+ ``.abi3+abi3t.so `` -- but this would have no practical benefits over
837+ omitting the tag altogether -- that is, using bare ``.so ``.
838+ Specifically, bare ``.so `` meets the needs of :pep: `3149 ` (which introduced
839+ the filename tags): existing stable ABI extensions (``.abi3.so ``)
840+ and version-specific ABI extensions (``.cpNN-*.so ``) can be installed
841+ alongside the ``.so `` file, and will be preferred by interpreters that can
842+ load them.
843+
844+
845+
839846Reusing ``Py_GIL_DISABLED `` to enable the new ABI
840847-------------------------------------------------
841848
@@ -859,6 +866,28 @@ the ability to build for the GIL-only Stable ABI with no source changes
859866was deemed to be worth an extra configuration macro (``Py_TARGET_ABI3T ``).
860867
861868
869+ Making ``abi3t `` compatible with GIL-enabled builds
870+ ---------------------------------------------------
871+
872+ Initially, ``abi3t `` will be compatible with ``abi3 ``.
873+ It would be possible to promise that it will always be so.
874+ This would make the ``abi3.abi3t `` tag unnecessary;
875+ ``abi3t `` could be used instead.
876+
877+ In this case, installers would need to allow ``abi3t ``-tagged wheels
878+ for GIL-enabled builds of Python, needing a change in installers.
879+ Since installers written in Python typically use/vendor the :pypi: `packaging `
880+ library, this change would mostly be limited to one repository.
881+
882+ The wheel tag ``abi3.abi3t `` would be valid in this scenario;
883+ it could be used to support existing installers (which "know about" ``abi3 ``
884+ but not ``abi3t ``), to experiment with supporting Python 3.14, and in similar
885+ cases.
886+
887+ However, this would prevent the possibility of ever making ``abi3 ``
888+ and ``abi3t `` diverge.
889+
890+
862891Copyright
863892=========
864893
0 commit comments