diff options
Diffstat (limited to 'setuptools/wheel.py')
-rw-r--r-- | setuptools/wheel.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/setuptools/wheel.py b/setuptools/wheel.py index 4a33b203..e171a979 100644 --- a/setuptools/wheel.py +++ b/setuptools/wheel.py @@ -20,7 +20,7 @@ WHEEL_NAME = re.compile( r"""^(?P<project_name>.+?)-(?P<version>\d.*?) ((-(?P<build>\d.*?))?-(?P<py_version>.+?)-(?P<abi>.+?)-(?P<platform>.+?) )\.whl$""", -re.VERBOSE).match + re.VERBOSE).match NAMESPACE_PACKAGE_INIT = '''\ try: @@ -95,16 +95,21 @@ class Wheel(object): dist_basename = '%s-%s' % (self.project_name, self.version) dist_info = self.get_dist_info(zf) dist_data = '%s.data' % dist_basename + def get_metadata(name): with zf.open(posixpath.join(dist_info, name)) as fp: value = fp.read().decode('utf-8') if PY3 else fp.read() return email.parser.Parser().parsestr(value) wheel_metadata = get_metadata('WHEEL') - dist_metadata = get_metadata('METADATA') # Check wheel format version is supported. wheel_version = parse_version(wheel_metadata.get('Wheel-Version')) - if not parse_version('1.0') <= wheel_version < parse_version('2.0dev0'): - raise ValueError('unsupported wheel format version: %s' % wheel_version) + wheel_v1 = ( + parse_version('1.0') <= wheel_version + < parse_version('2.0dev0') + ) + if not wheel_v1: + raise ValueError( + 'unsupported wheel format version: %s' % wheel_version) # Extract to target directory. os.mkdir(destination_eggdir) zf.extractall(destination_eggdir) @@ -114,8 +119,9 @@ class Wheel(object): destination_eggdir, dist_info, metadata=PathMetadata(destination_eggdir, dist_info) ) - # Note: we need to evaluate and strip markers now, - # as we can't easily convert back from the syntax: + + # Note: Evaluate and strip markers now, + # as it's difficult to convert back from the syntax: # foobar; "linux" in sys_platform and extra == 'test' def raw_req(req): req.marker = None @@ -163,13 +169,16 @@ class Wheel(object): if os.path.exists(dist_data): os.rmdir(dist_data) # Fix namespace packages. - namespace_packages = os.path.join(egg_info, 'namespace_packages.txt') + namespace_packages = os.path.join( + egg_info, 'namespace_packages.txt') if os.path.exists(namespace_packages): with open(namespace_packages) as fp: namespace_packages = fp.read().split() for mod in namespace_packages: mod_dir = os.path.join(destination_eggdir, *mod.split('.')) mod_init = os.path.join(mod_dir, '__init__.py') - if os.path.exists(mod_dir) and not os.path.exists(mod_init): + if ( + os.path.exists(mod_dir) + and not os.path.exists(mod_init)): with open(mod_init, 'w') as fp: fp.write(NAMESPACE_PACKAGE_INIT) |