5
5
#
6
6
"""Implementation of the Metadata for Python packages PEPs.
7
7
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 ).
9
9
"""
10
10
from __future__ import unicode_literals
11
11
@@ -89,13 +89,20 @@ class MetadataInvalidError(DistlibException):
89
89
90
90
_643_FIELDS = _566_FIELDS + _643_MARKERS
91
91
92
+ # PEP 771
93
+ _771_MARKERS = ('Default-Extra' )
94
+
95
+ _771_FIELDS = _643_FIELDS + _771_MARKERS
96
+
97
+
92
98
_ALL_FIELDS = set ()
93
99
_ALL_FIELDS .update (_241_FIELDS )
94
100
_ALL_FIELDS .update (_314_FIELDS )
95
101
_ALL_FIELDS .update (_345_FIELDS )
96
102
_ALL_FIELDS .update (_426_FIELDS )
97
103
_ALL_FIELDS .update (_566_FIELDS )
98
104
_ALL_FIELDS .update (_643_FIELDS )
105
+ _ALL_FIELDS .update (_771_FIELDS )
99
106
100
107
EXTRA_RE = re .compile (r'''extra\s*==\s*("([^"]+)"|'([^']+)')''' )
101
108
@@ -115,6 +122,8 @@ def _version2fieldlist(version):
115
122
# return _426_FIELDS
116
123
elif version == '2.2' :
117
124
return _643_FIELDS
125
+ elif version == '2.5' :
126
+ return _771_FIELDS
118
127
raise MetadataUnrecognizedVersionError (version )
119
128
120
129
@@ -125,7 +134,7 @@ def _has_marker(keys, markers):
125
134
return any (marker in keys for marker in markers )
126
135
127
136
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
129
138
130
139
# first let's try to see if a field is not part of one of the version
131
140
for key in keys :
@@ -148,6 +157,9 @@ def _has_marker(keys, markers):
148
157
if key not in _643_FIELDS and '2.2' in possible_versions :
149
158
possible_versions .remove ('2.2' )
150
159
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 )
151
163
# if key not in _426_FIELDS and '2.0' in possible_versions:
152
164
# possible_versions.remove('2.0')
153
165
# logger.debug('Removed 2.0 due to %s', key)
@@ -165,16 +177,19 @@ def _has_marker(keys, markers):
165
177
is_2_1 = '2.1' in possible_versions and _has_marker (keys , _566_MARKERS )
166
178
# is_2_0 = '2.0' in possible_versions and _has_marker(keys, _426_MARKERS)
167
179
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' )
170
184
171
185
# we have the choice, 1.0, or 1.2, 2.1 or 2.2
172
186
# - 1.0 has a broken Summary field but works with all tools
173
187
# - 1.1 is to avoid
174
188
# - 1.2 fixes Summary but has little adoption
175
189
# - 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 :
178
193
# we couldn't find any specific marker
179
194
if PKG_INFO_PREFERRED_VERSION in possible_versions :
180
195
return PKG_INFO_PREFERRED_VERSION
@@ -184,10 +199,10 @@ def _has_marker(keys, markers):
184
199
return '1.2'
185
200
if is_2_1 :
186
201
return '2.1'
187
- # if is_2_2:
188
- # return '2.2'
202
+ if is_2_2 :
203
+ return '2.2'
189
204
190
- return '2.2 '
205
+ return '2.5 '
191
206
192
207
193
208
# This follows the rules about transforming keys as described in
0 commit comments