|
| 1 | +PEP: 566 |
| 2 | +Title: Metadata for Python Software Packages 1.3 |
| 3 | +Version: $Revision$ |
| 4 | +Last-Modified: $Date$ |
| 5 | +Author: Dustin Ingram < [email protected]> |
| 6 | +Discussions-To: distutils-sig <distutils-sig at python.org> |
| 7 | +Status: Draft |
| 8 | +Type: Standards Track |
| 9 | +Content-Type: text/x-rst |
| 10 | +Created: 1-Dec-2017 |
| 11 | +Python-Version: 3.x |
| 12 | +Post-History: |
| 13 | +Replaces: 345 |
| 14 | + |
| 15 | + |
| 16 | +Abstract |
| 17 | +======== |
| 18 | + |
| 19 | +This PEP describes the changes between versions 1.2 and 1.3 of the core |
| 20 | +metadata specification for Python packages. Version 1.2 is specified in PEP |
| 21 | +345. |
| 22 | + |
| 23 | +It also changes to the canonical source for field specifications to the `Core |
| 24 | +Metadata Specification`_ reference document, which includes specifics of the |
| 25 | +field names, and their semantics and usage. |
| 26 | + |
| 27 | +Fields |
| 28 | +====== |
| 29 | + |
| 30 | +The canonical source for the names and semantics of each of the supported |
| 31 | +metadata fields is the `Core Metadata Specification`_ document. |
| 32 | + |
| 33 | +Fields marked with "(Multiple use)" may be specified multiple times in a single |
| 34 | +PKG-INFO file. Other fields may only occur once in a PKG-INFO file. Fields |
| 35 | +marked with "(optional)" are not required to appear in a valid PKG-INFO file; |
| 36 | +all other fields must be present. |
| 37 | + |
| 38 | +New in Version 1.3 |
| 39 | +------------------ |
| 40 | + |
| 41 | +Description-Content-Type (optional) |
| 42 | +::::::::::::::::::::::::::::::::::: |
| 43 | + |
| 44 | +A string stating the markup syntax (if any) used in the distribution's |
| 45 | +description, so that tools can intelligently render the description. |
| 46 | + |
| 47 | +Historically, tools like PyPI assume that a package's description is formatted |
| 48 | +in `reStructuredText (reST) |
| 49 | +<http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html>`_, and |
| 50 | +fall back on plain text if the description is not valid reST. |
| 51 | + |
| 52 | +The introduction of this field allows PyPI to support additional types of |
| 53 | +markup syntax, and not need to make this assumption. |
| 54 | + |
| 55 | +The full specification for this field is defined in the `Core Metadata |
| 56 | +Specification`_. |
| 57 | + |
| 58 | + |
| 59 | +Provides-Extra (optional, multiple use) |
| 60 | +::::::::::::::::::::::::::::::::::::::: |
| 61 | + |
| 62 | +A string containing the name of an optional feature. Must be a valid Python |
| 63 | +identifier. May be used to make a dependency conditional on whether the |
| 64 | +optional feature has been requested. |
| 65 | + |
| 66 | +This introduction of this field allows packge installation tools (such as |
| 67 | +``pip``) to determine which extras are provided by a given package, and so that |
| 68 | +package publication tools (such as ``twine``) can check for issues with |
| 69 | +environment markers which use extras. |
| 70 | + |
| 71 | +The full specification for this field is defined in the `Core Metadata |
| 72 | +Specification`_. |
| 73 | + |
| 74 | +Changed in Version 1.3 |
| 75 | +---------------------- |
| 76 | + |
| 77 | +Name |
| 78 | +:::: |
| 79 | + |
| 80 | +The specification for the format of this field is now identical to the |
| 81 | +distribution name specification defined in PEP 508. |
| 82 | + |
| 83 | +Version Specifiers |
| 84 | +================== |
| 85 | + |
| 86 | +Version numbering requirements and the semantics for specifying comparisons |
| 87 | +between versions are defined in PEP 440. |
| 88 | + |
| 89 | +Environment markers |
| 90 | +=================== |
| 91 | + |
| 92 | +An **environment marker** is a marker that can be added at the end of a |
| 93 | +field after a semi-colon (";"), to add a condition about the execution |
| 94 | +environment. |
| 95 | + |
| 96 | +The environment marker format used to declare such a condition is defined in |
| 97 | +the environment markers section of PEP 508. |
| 98 | + |
| 99 | +JSON-compatible Metadata |
| 100 | +======================== |
| 101 | + |
| 102 | +It may be necessary to store metadata in a data structure which does not |
| 103 | +allow for multiple repeated keys, such as JSON. |
| 104 | + |
| 105 | +The canonical method to transform metadata fields into such a data structure is |
| 106 | +as follows: |
| 107 | + |
| 108 | +#. The original key-value format should be read with |
| 109 | + ``email.parser.HeaderParser``; |
| 110 | +#. All transformed keys should be reduced to lower case, but otherwise should |
| 111 | + retain all other characters; |
| 112 | +#. The transformed value for any field marked with "(Multiple-use") should be a |
| 113 | + single list containing all the original values for the given key; |
| 114 | +#. The ``Keywords`` field should be converted to a list by splitting the |
| 115 | + original value on whitespace characters; |
| 116 | +#. The result should be stored as a string-keyed dictionary. |
| 117 | + |
| 118 | +Summary of Differences From PEP 345 |
| 119 | +=================================== |
| 120 | + |
| 121 | +* Metadata-Version is now 1.3. |
| 122 | + |
| 123 | +* Fields are now specified via the `Core Metadata Specification`_. |
| 124 | + |
| 125 | +* Added two new fields: ``Description-Content-Type`` and ``Provides-Extra`` |
| 126 | + |
| 127 | +* Acceptable values for the ``Name`` field are now specified as per PEP 508. |
| 128 | + |
| 129 | +* Added canonical method of transformation into JSON-compatible data structure. |
| 130 | + |
| 131 | +References |
| 132 | +========== |
| 133 | + |
| 134 | +This document specifies version 1.3 of the metadata format. |
| 135 | +Version 1.0 is specified in PEP 241. |
| 136 | +Version 1.1 is specified in PEP 314. |
| 137 | +Version 1.2 is specified in PEP 345. |
| 138 | + |
| 139 | +.. _`Core Metadata Specification`: |
| 140 | + https://packaging.python.org/specifications/core-metadata/ |
| 141 | + |
| 142 | +Copyright |
| 143 | +========= |
| 144 | + |
| 145 | +This document has been placed in the public domain. |
| 146 | + |
| 147 | +Acknowledgements |
| 148 | +================ |
| 149 | + |
| 150 | +Thanks to Nick Colgan for contributing to this PEP. |
| 151 | + |
| 152 | + |
| 153 | +.. |
| 154 | + Local Variables: |
| 155 | + mode: indented-text |
| 156 | + indent-tabs-mode: nil |
| 157 | + sentence-end-double-space: t |
| 158 | + fill-column: 80 |
| 159 | + End: |
0 commit comments