@@ -191,11 +191,12 @@ expressed as a frozen set of strings of the form ``f"{name}::{value}"``, where
191191``name `` is the name of the field and ``value `` is the string representation of
192192its value.
193193
194+ The ``sys_abi_info `` environment variable
195+ '''''''''''''''''''''''''''''''''''''''''
194196To do this, we need to extend the grammar laid out in :pep: `508 ` and maintained
195- in the :ref: `packaging:dependency-specifiers ` and document the possible values.
196-
197- The grammar is extended to include the ``sys_abi_info `` marker variable by
198- augmenting the definition of ``env_var `` as follows::
197+ in the :ref: `packaging:dependency-specifiers ` and document the possible values,
198+ to include the ``sys_abi_info `` marker variable by augmenting the definition of
199+ ``env_var `` as follows::
199200
200201 env_var = ('python_version' | 'python_full_version' |
201202 'os_name' | 'sys_platform' | 'platform_release' |
@@ -206,6 +207,10 @@ augmenting the definition of ``env_var`` as follows::
206207 'extra' | 'extras' | 'dependency_groups' # ONLY when defined by a containing layer
207208 )
208209
210+ This makes ``sys_abi_info `` available as a variable in marker expressions.
211+
212+ The Values of ``sys_abi_info ``
213+ ''''''''''''''''''''''''''''''
209214Like the grammar, also the overview table of environment markers in
210215:ref: `packaging:dependency-specifiers ` is augmented to add the following row:
211216
@@ -225,6 +230,31 @@ With these additions, ABI features can be used in dependency specifications via
225230the ``in `` operator to test for the presence of a feature, or the ``not in ``
226231operator to test for the absence of a feature.
227232
233+ This allows for marker expressions such as::
234+
235+ "free_threaded::True" in sys_abi_info
236+ "pointer_bits::32" not in sys_abi_info and "debug::True" in sys_abi_info
237+
238+ Note that this is forward compatible in the sense that future additions to the
239+ set of ABI features will not be in conflict with the grammar, such that tools
240+ encountering unknown ABI features in a dependency specification will naturally
241+ evaluate the test as false. This empowers package authors to decide on the
242+ default resolution in this case. For example, a package author may decide to
243+ require a dependency only if an ABI feature is present, by using a presence
244+ test like ``"new_feature::True" in sys_abi_info ``, which will evaluate to
245+ false on current interpreters that do not support the new feature, or an
246+ absence test like ``"new_feature::False" not in sys_abi_info ``, which will
247+ evaluate to true on current interpreters.
248+
249+ While covering all ABI features specified at the moment, this mechanism is only
250+ meaningfully applicable where the ABI feature is unambiguously representable as
251+ a string. Currently, all ABI features are either booleans, integers, or
252+ strings, which all satisfy this requirement.
253+
254+ Should the future reveal a need for ABI features that are not unambiguously
255+ represented as strings, like floating point numbers or more complex data
256+ structures, this PEP would need to be revisited to address those.
257+
228258Examples
229259========
230260
0 commit comments