44Core Metadata Specifications
55============================
66
7- The current core metadata file format, version 1.2, is specified in :pep: `345 `.
8-
9- However, in a forthcoming PEP, the following specification will be defined as
10- the canonical source for the core metadata file format. Fields which are
11- defined in this specification, but do not currently appear in any accepted PEP,
12- are marked as "New in version 1.3".
7+ The current core metadata file format, version 2.1, is specified in :pep: `566 `.
8+ It defines the following specification as the canonical source for the core
9+ metadata file format.
1310
1411Fields defined in the following specification should be considered valid,
1512complete and not subject to change. Fields should be considered "optional" for
1613versions which predate their introduction.
1714
15+ .. note :: *Interpreting old metadata:* In :pep:`566`, the version specifier
16+ field format specification was relaxed to accept the syntax used by popular
17+ publishing tools (namely to remove the requirement that version specifiers
18+ must be surrounded by parentheses). Metadata consumers may want to use the
19+ more relaxed formatting rules even for metadata files that are nominally
20+ less than version 2.1.
21+
1822.. contents :: Contents
1923 :local:
2024
@@ -24,7 +28,7 @@ Metadata-Version
2428
2529.. versionadded :: 1.0
2630
27- Version of the file format; legal values are "1.0", "1.1" and "1.2".
31+ Version of the file format; legal values are "1.0", "1.1", "1.2" and "2.1 ".
2832
2933Automated tools consuming metadata SHOULD warn if ``metadata_version `` is
3034greater than the highest version they support, and MUST fail if
@@ -38,15 +42,23 @@ all of the needed fields.
3842
3943Example::
4044
41- Metadata-Version: 1.2
45+ Metadata-Version: 2.1
4246
4347
4448Name
4549====
4650
4751.. versionadded :: 1.0
52+ .. versionchanged :: 2.1
53+ Added additional restrictions on format from :pep: `508 `
4854
49- The name of the distributions.
55+ The name of the distribution. The name field is the primary identifier for a
56+ distribution. A valid name consists only of ASCII letters and numbers, period,
57+ underscore and hyphen. It must start and end with a letter or number.
58+ Distribution names are limited to those which match the following
59+ regex (run with ``re.IGNORECASE ``)::
60+
61+ ^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$
5062
5163Example::
5264
@@ -113,6 +125,8 @@ Description (optional)
113125======================
114126
115127.. versionadded :: 1.0
128+ .. versionchanged :: 2.1
129+ This field may be specified in the message body instead.
116130
117131A longer description of the distribution that can run to several
118132paragraphs. Software that deals with metadata should not assume
@@ -146,11 +160,15 @@ This encoding implies that any occurrences of a CRLF followed by 7 spaces
146160and a pipe char have to be replaced by a single CRLF when the field is unfolded
147161using a RFC822 reader.
148162
163+ Alternatively, the distribution's description may instead be provided in the
164+ message body (i.e., after a completely blank line following the headers, with
165+ no indentation or other special formatting necessary).
166+
149167
150168Description-Content-Type (optional)
151169===================================
152170
153- .. versionadded :: 1.3
171+ .. versionadded :: 2.1
154172
155173A string stating the markup syntax (if any) used in the distribution's
156174description, so that tools can intelligently render the description.
@@ -384,6 +402,9 @@ Requires-Dist (multiple use)
384402============================
385403
386404.. versionadded :: 1.2
405+ .. versionchanged :: 2.1
406+ The field format specification was relaxed to accept the syntax used by
407+ popular publishing tools.
387408
388409Each entry contains a string naming some other distutils
389410project required by this distribution.
@@ -421,6 +442,9 @@ Provides-Dist (multiple use)
421442============================
422443
423444.. versionadded :: 1.2
445+ .. versionchanged :: 2.1
446+ The field format specification was relaxed to accept the syntax used by
447+ popular publishing tools.
424448
425449Each entry contains a string naming a Distutils project which
426450is contained within this distribution. This field *must * include
@@ -459,6 +483,9 @@ Obsoletes-Dist (multiple use)
459483=============================
460484
461485.. versionadded :: 1.2
486+ .. versionchanged :: 2.1
487+ The field format specification was relaxed to accept the syntax used by
488+ popular publishing tools.
462489
463490Each entry contains a string describing a distutils project's distribution
464491which this distribution renders obsolete, meaning that the two projects
@@ -506,6 +533,9 @@ Requires-External (multiple use)
506533================================
507534
508535.. versionadded :: 1.2
536+ .. versionchanged :: 2.1
537+ The field format specification was relaxed to accept the syntax used by
538+ popular publishing tools.
509539
510540Each entry contains a string describing some dependency in the
511541system that the distribution is to be used. This field is intended to
@@ -551,7 +581,7 @@ The label is a free text limited to 32 signs.
551581Provides-Extra (optional, multiple use)
552582=======================================
553583
554- .. versionadded :: 1.3
584+ .. versionadded :: 2.1
555585
556586A string containing the name of an optional feature. Must be a valid Python
557587identifier. May be used to make a dependency conditional on whether the
0 commit comments