@@ -45,8 +45,8 @@ Metadata-Version
45
45
46
46
.. versionadded :: 1.0
47
47
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 ".
50
50
51
51
Automated tools consuming metadata SHOULD warn if ``metadata_version `` is
52
52
greater than the highest version they support, and MUST fail if
@@ -60,7 +60,7 @@ all of the needed fields.
60
60
61
61
Example::
62
62
63
- Metadata-Version: 2.2
63
+ Metadata-Version: 2.3
64
64
65
65
66
66
.. _core-metadata-name :
@@ -84,6 +84,12 @@ Example::
84
84
85
85
Name: BeagleVote
86
86
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()
87
93
88
94
.. _core-metadata-version :
89
95
@@ -510,7 +516,8 @@ The format of a requirement string contains from one to four parts:
510
516
The only mandatory part.
511
517
* A comma-separated list of 'extra' names. These are defined by
512
518
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.
514
521
* A version specifier. Tools parsing the format should accept optional
515
522
parentheses around this, but tools generating it should not use
516
523
parentheses.
@@ -613,9 +620,20 @@ Provides-Extra (multiple use)
613
620
=============================
614
621
615
622
.. 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])$
616
634
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
619
637
optional feature has been requested.
620
638
621
639
Example::
@@ -640,6 +658,17 @@ respectively.
640
658
It is legal to specify ``Provides-Extra: `` without referencing it in any
641
659
``Requires-Dist: ``.
642
660
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
+
643
672
644
673
Rarely Used Fields
645
674
==================
0 commit comments