File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed
Filter options
Expand file tree Collapse file tree 3 files changed +8
-2
lines changed
Original file line number Diff line number Diff line change 21
21
import pkg_resources
22
22
import re
23
23
import zipfile
24
+ import sys
24
25
25
26
EXTRA_RE = re .compile ("""^(?P<package>.*?)(;\s*(?P<condition>.*?)(extra == '(?P<extra>.*?)')?)$""" )
26
27
MayRequiresKey = collections .namedtuple ('MayRequiresKey' , ('condition' , 'extra' ))
@@ -49,7 +50,7 @@ def version(self):
49
50
50
51
def repository_name (self ):
51
52
# Returns the canonical name of the Bazel repository for this package.
52
- canonical = 'pypi__{} _{}' .format (self .distribution (), self .version ())
53
+ canonical = 'pypi__py{}__{} _{}' .format (sys . version_info . major , self .distribution (), self .version ())
53
54
# Escape any illegal characters with underscore.
54
55
return re .sub ('[-.+]' , '_' , canonical )
55
56
@@ -117,7 +118,12 @@ def expand(self, directory):
117
118
# _parse_metadata parses METADATA files according to https://www.python.org/dev/peps/pep-0314/
118
119
def _parse_metadata (self , content ):
119
120
metadata = {}
120
- pkg_info = email .parser .Parser ().parse (content )
121
+ content_str = content .read ()
122
+ try :
123
+ pkg_info = email .parser .Parser ().parsestr (content_str )
124
+ except :
125
+ pkg_info = email .parser .BytesParser ().parsebytes (content_str )
126
+
121
127
metadata ['name' ] = pkg_info .get ('Name' )
122
128
extras = pkg_info .get_all ('Provides-Extra' )
123
129
if extras :
You can’t perform that action at this time.
0 commit comments