Skip to content

Commit 14f2097

Browse files
committed
Attempt to clarify legacy extra syntax definition
1 parent 32bc5cb commit 14f2097

1 file changed

Lines changed: 28 additions & 16 deletions

File tree

source/specifications/dependency-specifiers.rst

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -442,27 +442,39 @@ of the following marker fields:
442442
SHOULD NOT accept uploads containing such environment markers)
443443

444444
For backwards compatibility with older locking and installation tools, the
445-
``extras`` and ``dependency_groups`` fields are currently only considered
446-
valid in :ref:`lock files <lock-file-spec>` (where they allow consumers of the
447-
lock file to selectively install optional parts of the locked dependency tree).
448-
Publishing tools SHOULD emit an error if projects attempt to use them in their
449-
published metadata, and index servers SHOULD NOT accept uploads referencing
445+
``extras`` and ``dependency_groups`` fields are currently only valid for use in
446+
``packages.marker`` fields in :ref:`lock files <lock-file-spec>`. For these
447+
comparisons, the ``extras`` and ``dependency_groups`` sets used for the marker
448+
evaluation refer to the *currently selected* extras and dependency groups when
449+
installing from the lock file, not the full set of defined extras and dependency
450+
groups listed in the corresponding top level lock file fields. The interface
451+
for selecting which extras and dependency groups to install is tool dependent.
452+
Publishing tools SHOULD emit an error if projects attempt to reference the
453+
``extras`` or ``dependency_groups`` fields in their published dependency
454+
declaration metadata, and index servers SHOULD NOT accept uploads referencing
450455
these fields. Outside lock file processing, marker evaluation environments
451456
DO NOT need to define these fields.
452457

453458
The ``extra`` field is also special, as it expects set-like behaviour, but
454459
predates the addition of ``Set of strings`` as a defined marker field type.
455-
Accordingly, for this field only, ``extra == "name"`` is equivalent to
456-
``"name" in extras``, while ``extra != "name"`` is equivalent to
457-
``"name" not in extras``. Other comparison operations on ``extra`` are not
458-
defined and publishing tools SHOULD emit an error, index servers MAY disallow
459-
uploads containing such environment markers, while locking and
460-
installation tools SHOULD evaluate them as False. Unlike the newer ``extras``
461-
field, environment markers using this field SHOULD be accepted by both
462-
publishing tools and index servers. Marker evaluation environments intended
463-
for project dependency declarations will typically need to handle evaluation
464-
of ``extra`` field comparisons, while other evaluations of environment markers
465-
will not generally need to do so.
460+
Accordingly, ``extra == "name"`` in a dependency declaration is similar to
461+
``"name" in extras``, while ``extra != "name"`` is similar to
462+
``"name" not in extras``. For dependency marker evaluations, the set of extra
463+
names used for these comparisons is the full set of requested extras for *that
464+
particular package*, whether requested directly in a top level dependency
465+
declaration, or indirectly in a transitive dependency declaration. Other
466+
comparison operations on ``extra`` are not defined and publishing tools SHOULD
467+
emit an error, index servers MAY disallow uploads containing such environment
468+
markers, while locking and installation tools SHOULD evaluate them as False.
469+
470+
Unlike the newer ``extras`` field, environment markers using this field SHOULD
471+
be accepted by both publishing tools and index servers. Marker evaluation
472+
environments intended for project dependency declarations will typically need
473+
to handle evaluation of ``extra`` field comparisons, while other evaluations
474+
of environment markers will not generally need to do so. The legacy ``extra``
475+
comparison syntax is NOT permitted in lock file ``packages.marker`` fields,
476+
and installation tools SHOULD reject lock files containing such comparisons as
477+
invalid.
466478

467479
The ``implementation_version`` marker variable is derived from
468480
:py:data:`sys.implementation.version <sys.implementation>`:

0 commit comments

Comments
 (0)