Important
This PEP is a historical document. The up-to-date, canonical spec,Core metadata specifications, is maintained on thePyPA specs page.
×
See thePyPA specification update process for how to propose changes.
This PEP describes the changes between versions 1.2 and 2.1 of the coremetadata specification for Python packages. Version 1.2 is specified inPEP 345.
It also changes to the canonical source for field specifications to theCoreMetadata Specification reference document, which includes specifics of thefield names, and their semantics and usage.
The canonical source for the names and semantics of each of the supportedmetadata fields is theCore Metadata Specification document.
Fields marked with “(Multiple use)” may be specified multiple times in a singlePKG-INFO file. Other fields may only occur once in a PKG-INFO file. Fieldsmarked with “(optional)” are not required to appear in a valid PKG-INFO file;all other fields must be present.
A string stating the markup syntax (if any) used in the distribution’sdescription, so that tools can intelligently render the description.
Historically, tools like PyPI assume that a package’s description is formattedinreStructuredText (reST), andfall back on plain text if the description is not valid reST.
The introduction of this field allows PyPI to support additional types ofmarkup syntax, and not need to make this assumption.
The full specification for this field is defined in theCore MetadataSpecification.
A string containing the name of an optional feature. Must be a valid Pythonidentifier. May be used to make a dependency conditional on whether theoptional feature has been requested.
This introduction of this field allows package installation tools (such aspip) to determine which extras are provided by a given package, and so thatpackage publication tools (such astwine) can check for issues withenvironment markers which use extras.
The full specification for this field is defined in theCore MetadataSpecification.
The specification for the format of this field is now identical to thedistribution name specification defined inPEP 508.
In addition to theDescription header field, the distribution’sdescription may instead be provided in the message body (i.e., after acompletely blank line following the headers, with no indentation or otherspecial formatting necessary).
Version numbering requirements and the semantics for specifying comparisonsbetween versions are defined inPEP 440. Direct references as defined inPEP 440 are also permitted as an alternative to version specifiers.
FollowingPEP 508, version specifiers no longer need to be surrounded byparentheses in the fields Requires-Dist, Provides-Dist, Obsoletes-Dist orRequires-External, so e.g.requests>=2.8.1 is now a valid value.The recommended format is without parentheses, but tools parsing metadata shouldalso be able to handle version specifiers in parentheses. Further, public indexservers MAY prohibit strict version matching clauses or direct references inthese fields.
Usage of version specifiers is otherwise unchanged fromPEP 345.
Anenvironment marker is a marker that can be added at the end of afield after a semi-colon (“;”), to add a condition about the executionenvironment.
The environment marker format used to declare such a condition is defined inthe environment markers section ofPEP 508.
Usage of environment markers is otherwise unchanged fromPEP 345.
It may be necessary to store metadata in a data structure which does notallow for multiple repeated keys, such as JSON.
The canonical method to transform metadata fields into such a data structure isas follows:
email.parser.HeaderParser;Keywords field should be converted to a list by splitting theoriginal value on commas;description key.Description-Content-Type andProvides-ExtraName field are now specified as perPEP 508.This document specifies version 2.1 of the metadata format.Version 1.0 is specified inPEP 241.Version 1.1 is specified inPEP 314.Version 1.2 is specified inPEP 345.Version 2.0, while not formally accepted, was specified inPEP 426.
This document has been placed in the public domain.
Thanks to Alyssa Coghlan and Thomas Kluyver for contributing to this PEP.
Source:https://github.com/python/peps/blob/main/peps/pep-0566.rst
Last modified:2025-02-01 08:55:40 GMT