Skip to content

Commit fd2c2e2

Browse files
committed
Updates from my own PR review
1 parent 28d4b58 commit fd2c2e2

4 files changed

Lines changed: 52 additions & 20 deletions

File tree

source/specifications/core-metadata.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,14 +574,14 @@ The format of a requirement string contains from one to four parts:
574574
* An environment marker after a semicolon. This means that the
575575
requirement is only needed in the specified conditions.
576576

577-
See :ref:`dependency-specifiers` for full details of the allowed format.
578-
579577
The project names should correspond to names as found
580578
on the `Python Package Index`_.
581579

582580
Version specifiers must follow the rules described in
583581
:doc:`version-specifiers`.
584582

583+
See :ref:`dependency-specifiers` for full details of the allowed format.
584+
585585
Examples::
586586

587587
Requires-Dist: pkginfo

source/specifications/dependency-specifiers.rst

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ The follow comparison operations are defined in the marker expression grammar:
243243
* ``<=`` (for example, ``python_version <= "3.10"``)
244244
* ``~=`` (for example, ``python_version ~= "3"``)
245245
* ``===`` (for example, ``implementation_version === "not.a.valid.version"``)
246-
* ``in`` (for example, ``"gui" in extras``)
246+
* ``in`` (for example, ``"gui" in extras``, ``"SMP" in platform_version``)
247247
* ``not in`` (for example, ``"dev" not in dependency_groups``)
248248

249249
For ``String`` fields, ``==``, ``!=``, ``in``, and ``not in`` are defined as
@@ -272,12 +272,17 @@ emit an error if the user supplied constant cannot be parsed as a valid version
272272
specifier, while locking and installation tools MAY either emit an error or else
273273
fall back to ``String`` field comparison logic if either the marker field value
274274
or the user supplied constant cannot be parsed as a valid version specifier.
275+
Note that ``in`` and ``not in`` containment checks are NOT valid for ``Version``
276+
fields.
275277

276278
For ``Version | String`` fields, comparison operations are defined as they are
277279
for ``Version`` fields. However, there is no expectation that the parsing of
278280
the marker field value or the user supplied constant as a valid version will
279281
succeed, so tools MUST fall back to processing the field as a ``String`` field.
280282
Alternatively, tools MAY unconditionally treat such fields as ``String`` fields.
283+
Accordingly, comparisons that rely on these fields being processed as
284+
``Version`` field SHOULD NOT be used in environment markers published to public
285+
index servers, but they may be appropriate in more constrained environments.
281286

282287
Composing marker expressions
283288
''''''''''''''''''''''''''''
@@ -286,8 +291,15 @@ More complex marker expressions may be composed using the ``and`` and ``or``
286291
logical operators. Parentheses may be used as necessary to control operand
287292
precedence (with all comparison operations having a higher precedence).
288293

294+
For example::
295+
296+
sys_platform == "ios" or sys_platform == "darwin"
297+
sys_platform == "linux" and "SMP" in platform_version
298+
sys_platform == "darwin" and platform_version >= "12"
299+
289300
Python's comparison chaining (such as ``3.4 < python_version < 3.9``) is NOT
290-
supported in environment markers.
301+
supported in environment markers (such expressions must instead be written out
302+
as two separate comparisons joined by ``and``).
291303

292304
User supplied constants
293305
'''''''''''''''''''''''

source/specifications/entry-points.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ Within a value, readers must accept and ignore spaces (including multiple
106106
consecutive spaces) before or after the colon, between the object reference and
107107
the left square bracket, between the extra names and the square brackets and
108108
colons delimiting them, and after the right square bracket. The syntax for
109-
extras is formally specified as part of :pep:`508` (as ``extras``) and
110-
restrictions on values specified in :pep:`685`.
109+
extras is formally specified in :ref:`dependency-specifiers`.
111110
For tools writing the file, it is recommended only to insert a space between the
112111
object reference and the left square bracket.
113112

source/specifications/pyproject-toml.rst

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -449,36 +449,57 @@ be ambiguous in the face of ``[project.scripts]`` and
449449

450450

451451
.. _pyproject-toml-dependencies:
452-
.. _pyproject-toml-optional-dependencies:
453452

454-
``dependencies``/``optional-dependencies``
455-
------------------------------------------
453+
``dependencies``
454+
----------------
456455

457-
- TOML_ type: Array of :ref:`dependency-specifiers` strings (``dependencies``),
458-
and a table with values of arrays of :ref:`dependency-specifiers` strings
459-
(``optional-dependencies``)
456+
- TOML_ type: Array of :ref:`dependency specifier <dependency-specifiers>`
457+
strings (``dependencies``)
460458
- Corresponding :ref:`core metadata <core-metadata>` field:
461-
:ref:`Requires-Dist <core-metadata-requires-dist>` and
462-
:ref:`Provides-Extra <core-metadata-provides-extra>`
459+
:ref:`Requires-Dist <core-metadata-requires-dist>`
463460

464-
The (optional) dependencies of the project.
461+
``dependencies`` lists the expected dependencies of the project as an
462+
array of strings.
465463

466-
For ``dependencies``, it is a key whose value is an array of strings.
467464
Each string represents a dependency of the project and MUST be
468-
formatted as a valid :ref:`dependency-specifiers` string.
465+
formatted as a valid :ref:`dependency specifier <dependency-specifiers>`.
466+
469467
Each string maps directly to a
470468
:ref:`Requires-Dist <core-metadata-requires-dist>` entry.
471469

472-
For ``optional-dependencies``, it is a table where each key specifies
473-
an extra and whose value is an array of strings. The strings of the
474-
arrays must be valid :ref:`dependency-specifiers` strings.
470+
Dependencies listed in this array are always considered
471+
for installation, but may still contain environment markers that cause them
472+
to be skipped in some environments.
473+
474+
475+
.. _pyproject-toml-optional-dependencies:
476+
477+
``optional-dependencies``
478+
-------------------------
479+
480+
- TOML_ type: table with string keys mapping to arrays of
481+
:ref:`dependency specifier <dependency-specifiers>` strings (``optional-dependencies``)
482+
- Corresponding :ref:`core metadata <core-metadata>` fields:
483+
:ref:`Requires-Dist <core-metadata-requires-dist>` and
484+
:ref:`Provides-Extra <core-metadata-provides-extra>`
485+
486+
``optional-dependencies`` is a table where each key specifies
487+
an extra and whose value is an array of strings using the same format as the
488+
``dependencies`` array (the strings in the
489+
arrays must be valid :ref:`dependency specifiers <dependency-specifiers>`).
490+
475491
The keys MUST be valid values
476492
for :ref:`Provides-Extra <core-metadata-provides-extra>`. Each value
477493
in the array thus becomes a corresponding
478494
:ref:`Requires-Dist <core-metadata-requires-dist>` entry for the
479495
matching :ref:`Provides-Extra <core-metadata-provides-extra>`
480496
metadata.
481497

498+
The optionality of these dependencies is recorded by modifying the environment
499+
marker clause on the related ``Requires-Dist`` entries to check the extra name.
500+
Optional dependencies are thus only considered for installation if installation
501+
if the associated extra name is requested.
502+
482503

483504
.. _pyproject-toml-import-names:
484505

0 commit comments

Comments
 (0)