55#
66"""Implementation of the Metadata for Python packages PEPs.
77
8- Supports all metadata formats (1.0, 1.1, 1.2, 1.3/2.1 and 2.2 ).
8+ Supports all metadata formats (1.0, 1.1, 1.2, 1.3/2.1, 2.2, 2.3, 2.4 and 2.5 ).
99"""
1010from __future__ import unicode_literals
1111
@@ -89,13 +89,20 @@ class MetadataInvalidError(DistlibException):
8989
9090_643_FIELDS = _566_FIELDS + _643_MARKERS
9191
92+ # PEP 771
93+ _771_MARKERS = ('Default-Extra' )
94+
95+ _771_FIELDS = _643_FIELDS + _771_MARKERS
96+
97+
9298_ALL_FIELDS = set ()
9399_ALL_FIELDS .update (_241_FIELDS )
94100_ALL_FIELDS .update (_314_FIELDS )
95101_ALL_FIELDS .update (_345_FIELDS )
96102_ALL_FIELDS .update (_426_FIELDS )
97103_ALL_FIELDS .update (_566_FIELDS )
98104_ALL_FIELDS .update (_643_FIELDS )
105+ _ALL_FIELDS .update (_771_FIELDS )
99106
100107EXTRA_RE = re .compile (r'''extra\s*==\s*("([^"]+)"|'([^']+)')''' )
101108
@@ -115,6 +122,8 @@ def _version2fieldlist(version):
115122 # return _426_FIELDS
116123 elif version == '2.2' :
117124 return _643_FIELDS
125+ elif version == '2.5' :
126+ return _771_FIELDS
118127 raise MetadataUnrecognizedVersionError (version )
119128
120129
@@ -125,7 +134,7 @@ def _has_marker(keys, markers):
125134 return any (marker in keys for marker in markers )
126135
127136 keys = [key for key , value in fields .items () if value not in ([], 'UNKNOWN' , None )]
128- possible_versions = ['1.0' , '1.1' , '1.2' , '1.3' , '2.1' , '2.2' ] # 2.0 removed
137+ possible_versions = ['1.0' , '1.1' , '1.2' , '1.3' , '2.1' , '2.2' , '2.5' ] # 2.0 removed
129138
130139 # first let's try to see if a field is not part of one of the version
131140 for key in keys :
@@ -148,6 +157,9 @@ def _has_marker(keys, markers):
148157 if key not in _643_FIELDS and '2.2' in possible_versions :
149158 possible_versions .remove ('2.2' )
150159 logger .debug ('Removed 2.2 due to %s' , key )
160+ if key not in _771_FIELDS and '2.5' in possible_versions :
161+ possible_versions .remove ('2.5' )
162+ logger .debug ('Removed 2.5 due to %s' , key )
151163 # if key not in _426_FIELDS and '2.0' in possible_versions:
152164 # possible_versions.remove('2.0')
153165 # logger.debug('Removed 2.0 due to %s', key)
@@ -165,16 +177,19 @@ def _has_marker(keys, markers):
165177 is_2_1 = '2.1' in possible_versions and _has_marker (keys , _566_MARKERS )
166178 # is_2_0 = '2.0' in possible_versions and _has_marker(keys, _426_MARKERS)
167179 is_2_2 = '2.2' in possible_versions and _has_marker (keys , _643_MARKERS )
168- if int (is_1_1 ) + int (is_1_2 ) + int (is_2_1 ) + int (is_2_2 ) > 1 :
169- raise MetadataConflictError ('You used incompatible 1.1/1.2/2.1/2.2 fields' )
180+ is_2_5 = '2.5' in possible_versions and _has_marker (keys , _771_MARKERS )
181+
182+ if int (is_1_1 ) + int (is_1_2 ) + int (is_2_1 ) + int (is_2_2 ) + int (is_2_5 ) > 1 :
183+ raise MetadataConflictError ('You used incompatible 1.1/1.2/2.1/2.2/2.5 fields' )
170184
171185 # we have the choice, 1.0, or 1.2, 2.1 or 2.2
172186 # - 1.0 has a broken Summary field but works with all tools
173187 # - 1.1 is to avoid
174188 # - 1.2 fixes Summary but has little adoption
175189 # - 2.1 adds more features
176- # - 2.2 is the latest
177- if not is_1_1 and not is_1_2 and not is_2_1 and not is_2_2 :
190+ # - 2.2 adds more features
191+ # - 2.5 is the latest
192+ if not is_1_1 and not is_1_2 and not is_2_1 and not is_2_2 and not is_2_5 :
178193 # we couldn't find any specific marker
179194 if PKG_INFO_PREFERRED_VERSION in possible_versions :
180195 return PKG_INFO_PREFERRED_VERSION
@@ -184,10 +199,10 @@ def _has_marker(keys, markers):
184199 return '1.2'
185200 if is_2_1 :
186201 return '2.1'
187- # if is_2_2:
188- # return '2.2'
202+ if is_2_2 :
203+ return '2.2'
189204
190- return '2.2 '
205+ return '2.5 '
191206
192207
193208# This follows the rules about transforming keys as described in
0 commit comments