@@ -45,8 +45,8 @@ Metadata-Version
4545
4646.. versionadded :: 1.0
4747
48- Version of the file format; legal values are "1.0", "1.1", "1.2", "2.1"
49- and "2.2 ".
48+ Version of the file format; legal values are "1.0", "1.1", "1.2", "2.1",
49+ "2.2", and "2.3 ".
5050
5151Automated tools consuming metadata SHOULD warn if ``metadata_version `` is
5252greater than the highest version they support, and MUST fail if
@@ -60,7 +60,7 @@ all of the needed fields.
6060
6161Example::
6262
63- Metadata-Version: 2.2
63+ Metadata-Version: 2.3
6464
6565
6666.. _core-metadata-name :
@@ -84,6 +84,12 @@ Example::
8484
8585 Name: BeagleVote
8686
87+ To normalize a distribution name for comparison purposes, it should be
88+ lowercased with all runs of the characters ``. ``, ``- ``, or ``_ `` replaced with
89+ a single ``- `` character. This can be done using the following snippet of code
90+ (as specified in :pep: `503 `)::
91+
92+ re.sub(r"[-_.]+", "-", name).lower()
8793
8894.. _core-metadata-version :
8995
@@ -510,7 +516,8 @@ The format of a requirement string contains from one to four parts:
510516 The only mandatory part.
511517* A comma-separated list of 'extra' names. These are defined by
512518 the required project, referring to specific features which may
513- need extra dependencies.
519+ need extra dependencies. The names MUST conform to the restrictions
520+ specified by the ``Provides-Extra: `` field.
514521* A version specifier. Tools parsing the format should accept optional
515522 parentheses around this, but tools generating it should not use
516523 parentheses.
@@ -613,9 +620,20 @@ Provides-Extra (multiple use)
613620=============================
614621
615622.. versionadded :: 2.1
623+ .. versionchanged :: 2.3
624+ :pep: `685 ` restricted valid values to be unambiguous (i.e. no normalization
625+ required). For older metadata versions, value restrictions were brought into
626+ line with ``Name: `` and normalization rules were introduced.
627+
628+ A string containing the name of an optional feature. A valid name consists only
629+ of lowercase ASCII letters, ASCII numbers, and hyphen. It must start and end
630+ with a letter or number. Hyphens cannot be followed by another hyphen. Names are
631+ limited to those which match the following regex (which guarantees unambiguity)::
632+
633+ ^([a-z0-9]|[a-z0-9]([a-z0-9-](?!-))*[a-z0-9])$
616634
617- A string containing the name of an optional feature. Must be a valid Python
618- identifier. May be used to make a dependency conditional on whether the
635+
636+ The specified name may be used to make a dependency conditional on whether the
619637optional feature has been requested.
620638
621639Example::
@@ -640,6 +658,17 @@ respectively.
640658It is legal to specify ``Provides-Extra: `` without referencing it in any
641659``Requires-Dist: ``.
642660
661+ When writing data for older metadata versions, names MUST be normalized
662+ following the same rules used for the ``Name: `` field when performing
663+ comparisons. Tools writing metadata MUST raise an error if two
664+ ``Provides-Extra: `` entries would clash after being normalized.
665+
666+ When reading data for older metadata versions, tools SHOULD warn when values
667+ for this field would be invalid under newer metadata versions. If a value would
668+ be invalid following the rules for ``Name: `` in any core metadata version, the
669+ user SHOULD be warned and the value ignored to avoid ambiguity. Tools MAY choose
670+ to raise an error when reading an invalid name for older metadata versions.
671+
643672
644673Rarely Used Fields
645674==================
0 commit comments