@@ -23,33 +23,31 @@ Abstract
2323========
2424
2525This PEP defines using ABI features as environment markers for project
26- dependencies, through a new ``sys_abi_features `` environment marker.
27- :pep: `508 ` (later moved to :ref: `packaging:dependency-specifiers `) introduced
28- environment markers to specify dependencies based on rules that describe
29- when the dependency should be used.
30- This PEP extends the environment markers to allow specifying dependencies
31- based on specific ABI features of the Python interpreter.
32- For this, it defines a set of `ABI Features `_ and specifies how they are made
33- available for `environment markers <pep-780-sys_abi_features _>`_ as a new
34- marker variable, ``sys_abi_features ``.
26+ dependencies, through a new ``sys_abi_features `` environment marker. :pep: `508 `
27+ (later moved to :ref: `packaging:dependency-specifiers `) introduced environment
28+ markers to specify dependencies based on rules that describe when the
29+ dependency should be used. This PEP extends the environment markers to allow
30+ specifying dependencies based on specific ABI features of the Python
31+ interpreter. For this, it defines a set of `ABI Features `_ and specifies how
32+ they are made available for `environment markers <pep-780-sys_abi_features _>`_
33+ as a new marker variable, ``sys_abi_features ``.
3534
3635Motivation
3736==========
3837
3938In 2015, :pep: `508 ` established environment markers to specify dependencies
40- based on environment conditions.
41- The development of free-threaded CPython [#python-free-threading ]_
42- has underlined the need for an environment marker to discriminate between
43- different ABI features that the interpreter was built with.
44- For example, currently there is no way to distinguish between a GIL-enabled and
45- a free-threaded CPython interpreter with an environment marker. This leads to
46- real world issues for the adoption of free-threading and its incremental
47- rollout. When a Python package is being made compatible with free-threaded
48- CPython, it also needs all its build and runtime dependencies to be compatible.
49- Capturing the first version of a dependency that is compatible precisely in
50- metadata is currently not possible, and increasing the minimum version of a
51- dependency also for the GIL-enabled build is usually undesirable since it
52- unnecessarily limits compatibility between packages.
39+ based on environment conditions. The development of free-threaded CPython
40+ [#python-free-threading ]_ has underlined the need for an environment marker to
41+ discriminate between different ABI features that the interpreter was built
42+ with. For example, currently there is no way to distinguish between a
43+ GIL-enabled and a free-threaded CPython interpreter with an environment marker.
44+ This leads to real world issues for the adoption of free-threading and its
45+ incremental rollout. When a Python package is being made compatible with
46+ free-threaded CPython, it also needs all its build and runtime dependencies to
47+ be compatible. Capturing the first version of a dependency that is compatible
48+ precisely in metadata is currently not possible, and increasing the minimum
49+ version of a dependency also for the GIL-enabled build is usually undesirable
50+ since it unnecessarily limits compatibility between packages.
5351
5452Some concrete examples of such issues have been discussed in the `Environment
5553marker for free-threading `_ Discourse thread:
@@ -96,20 +94,18 @@ Rationale
9694=========
9795
9896The intention of this PEP is to introduce its core features with minimal impact
99- on the existing ecosystem.
100- The existing grammar proposed in :pep: `508 ` lends itself to a straightforward
101- extension to include the new environment marker.
97+ on the existing ecosystem. The existing grammar proposed in :pep: `508 ` lends
98+ itself to a straightforward extension to include the new environment marker.
10299
103100A Forward Looking View on Free-Threaded Python
104101----------------------------------------------
105102
106- :pep: `703 `, the accepted proposal for free threading, states that the
107- rollout of free-threaded Python should be gradual, which has been clarified
108- by the Python Steering Council in `the PEP 703 acceptance post `_ to mean a
109- three stage process over multiple releases. It is therefore important to make
110- sure that the mechanisms in this PEP are useable for Python interpreters where
111- either free-threading or non-free-threading could be the default or the only
112- option.
103+ :pep: `703 `, the accepted proposal for free threading, states that the rollout
104+ of free-threaded Python should be gradual, which has been clarified by the
105+ Python Steering Council in `the PEP 703 acceptance post `_ to mean a three stage
106+ process over multiple releases. It is therefore important to make sure that the
107+ mechanisms in this PEP are useable for Python interpreters where either
108+ free-threading or non-free-threading could be the default or the only option.
113109
114110At the time of writing, free-threaded Python is in Phase I: experimental phase.
115111In this phase, there is an acute need for the proposed environment markers to
@@ -120,11 +116,11 @@ As the number of packages with support increases, and particularly during
120116Phase II: Supported-but-not-default phase, we still anticipate a strong need
121117for the environment markers to help with the transition.
122118
123- As free-threaded Python enters into Phase III: Default phase, the need for
124- the environment markers will decrease, though at this point it is not clear
125- that the GIL-enabled Python will be completely phased out (it may remain
126- available as a non standard build option). If it persists, the inverse need for
127- the ABI feature detection may arise.
119+ As free-threaded Python enters into Phase III: Default phase, the need for the
120+ environment markers will decrease, though at this point it is not clear that
121+ the GIL-enabled Python will be completely phased out (it may remain available
122+ as a non standard build option). If it persists, the inverse need for the ABI
123+ feature detection may arise.
128124
129125Indeed, in all three phases it may be necessary for package authors to choose
130126specific versions of their dependencies based on the ABI features, with a shift
@@ -160,12 +156,11 @@ distinction between free-threaded and GIL-enabled interpreters is only relevant
160156for CPython 3.13 onwards, but the bitness of the interpreter is relevant for
161157all interpreters.
162158
163- All interpreters MUST handle the following ABI features as stated.
164- ABI features that are restricted to particular interpreters MUST NOT be
165- provided by other interpreters.
166- The features are subdivided into groups and for each group there MUST be
167- exactly one feature present, except when the group is marked as optional, in
168- which case there MUST be at most one feature present.
159+ All interpreters MUST handle the following ABI features as stated. ABI features
160+ that are restricted to particular interpreters MUST NOT be provided by other
161+ interpreters. The features are subdivided into groups and for each group there
162+ MUST be exactly one feature present, except when the group is marked as
163+ optional, in which case there MUST be at most one feature present.
169164
170165``free-threading `` or ``gil-enabled `` (only CPython)
171166 If the Python interpreter is free-threaded, the ``free-threading `` feature
@@ -176,8 +171,8 @@ which case there MUST be at most one feature present.
176171``debug `` (only CPython, optional)
177172 This ABI feature is reserved for the ``--with-pydebug `` build of CPython.
178173 If the interpreter is a CPython interpreter with ``Py_DEBUG `` capabilities,
179- the ``debug `` feature MUST be present.
180- On POSIX systems, this corresponds to ``"d" in sys.abiflags ``.
174+ the ``debug `` feature MUST be present. On POSIX systems, this corresponds
175+ to the Python expression ``"d" in sys.abiflags ``.
181176
182177``32-bit `` or ``64-bit `` (optional)
183178 The bitness of the interpreter, that is, whether it is a 32-bit or 64-bit
@@ -231,8 +226,8 @@ Examples
231226
232227Require Cython Pre-release for Free-Threaded Python
233228----------------------------------------------------
234- To require a pre-release of Cython only for a free-threaded Python
235- interpreter, the following dependency specification can be used::
229+ To require a pre-release of Cython only for a free-threaded Python interpreter,
230+ the following dependency specification can be used::
236231
237232 cython >3.1.0a1; "free-threading" in sys_abi_features
238233 cython ==3.0.*; "free-threading" not in sys_abi_features
@@ -258,9 +253,9 @@ This is a pure extension to the existing environment markers and does not
258253affect existing environment markers or dependency specifications, hence there
259254are no direct backwards compatibility concerns.
260255
261- However, the introduction of the feature has implications for a
262- number of ecosystem tools, especially those which attempt to support
263- examination of data in ``pyproject.toml `` and ``requirements.txt ``.
256+ However, the introduction of the feature has implications for a number of
257+ ecosystem tools, especially those which attempt to support examination of data
258+ in ``pyproject.toml `` and ``requirements.txt ``.
264259
265260Audit and Update Tools
266261----------------------
@@ -269,10 +264,9 @@ A wide range of tools understand Python dependency data as expressed in
269264``requirements.txt `` files. (e.g., Dependabot, Tidelift, etc)
270265
271266Such tools inspect dependency data and, in some cases, offer tool-assisted or
272- fully automated updates.
273- It is our expectation that no such tools would support the new environment
274- markers at first, and broad ecosystem support could take many months or even
275- some number of years to arrive.
267+ fully automated updates. It is our expectation that no such tools would support
268+ the new environment markers at first, and broad ecosystem support could take
269+ many months or even some number of years to arrive.
276270
277271As a result, users of the new environment markers would experience a
278272degradation in their workflows and tool support at the time that they start
@@ -294,11 +288,11 @@ dependencies may be specified here, just as they may be specified in
294288How to Teach This
295289=================
296290
297- The use of environment markers is well established and communicated chiefly
298- in :ref: `packaging:dependency-specifiers `.
299- The new environment marker can be introduced in the same document.
300- Additionally, both for package authors and users, free-threading specific
301- guidance can be provided at the `Python free-threading guide `_.
291+ The use of environment markers is well established and communicated chiefly in
292+ :ref: `packaging:dependency-specifiers `. The new environment marker can be
293+ introduced in the same document. Additionally, both for package authors and
294+ users, free-threading specific guidance can be provided at the
295+ `Python free-threading guide `_.
302296
303297Reference Implementation
304298========================
@@ -311,8 +305,8 @@ of the ``packaging`` library at `Environment markers for ABI features
311305also available.
312306
313307Since ``pip `` uses a vendored copy of ``packaging `` internally, we also provide
314- `a patched version of pip `__, which replaces the vendored ``packaging `` with the
315- reference implementation linked above.
308+ `a patched version of pip `__, which replaces the vendored ``packaging `` with
309+ the reference implementation linked above.
316310
317311__ https://github.com/zklaus/pip/tree/env-marker-free-threading
318312
@@ -349,16 +343,15 @@ Other Tooling
349343-------------
350344The reference implementation is based on the ``packaging `` library and ``pip ``.
351345We have confirmed that this allows for building and installing packages with
352- several build backends.
353- It is possible that other tools should be added to the reference
354- implementation.
346+ several build backends. It is possible that other tools should be added to the
347+ reference implementation.
355348
356349
357350Footnotes
358351=========
359352
360- .. [#python-free-threading ] Python experimental support for free threading
361- is available in Python 3.13 and later. For more information, see `Python
353+ .. [#python-free-threading ] Python experimental support for free threading is
354+ available in Python 3.13 and later. For more information, see `Python
362355 experimental support for free threading `_.
363356
364357 .. [#bitness ] While there are some related environment markers available, such
@@ -377,9 +370,9 @@ Footnotes
377370Acknowledgements
378371================
379372
380- Thanks to Filipe Laíns for the suggestion of the ``abi_features `` attribute
381- and to Stephen Rosen for the Backwards Compatibility section of :pep: `735 `,
382- which served as a template for the corresponding section in this PEP.
373+ Thanks to Filipe Laíns for the suggestion of the ``abi_features `` attribute and
374+ to Stephen Rosen for the Backwards Compatibility section of :pep: `735 `, which
375+ served as a template for the corresponding section in this PEP.
383376
384377Copyright
385378=========
0 commit comments