diff options
author | Arnon Yaari <arnony@infinidat.com> | 2018-05-14 17:10:29 +0300 |
---|---|---|
committer | Arnon Yaari <arnony@infinidat.com> | 2018-05-16 12:03:25 +0300 |
commit | 593b409fb66efcabe046e240a868b7dbcf1fc01b (patch) | |
tree | 719c62db75049b962dfbc8c4be3515529e8f78d0 /setuptools/wheel.py | |
parent | 5dddf7f26295af7ab9cd5dbf1e2b4472d7739187 (diff) | |
download | external_python_setuptools-593b409fb66efcabe046e240a868b7dbcf1fc01b.tar.gz external_python_setuptools-593b409fb66efcabe046e240a868b7dbcf1fc01b.tar.bz2 external_python_setuptools-593b409fb66efcabe046e240a868b7dbcf1fc01b.zip |
Use canonicalize_name to look for .dist-info in wheel files
Fixes issue #1350
Diffstat (limited to 'setuptools/wheel.py')
-rw-r--r-- | setuptools/wheel.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/setuptools/wheel.py b/setuptools/wheel.py index 37dfa531..4a33b203 100644 --- a/setuptools/wheel.py +++ b/setuptools/wheel.py @@ -4,10 +4,12 @@ from distutils.util import get_platform import email import itertools import os +import posixpath import re import zipfile from pkg_resources import Distribution, PathMetadata, parse_version +from setuptools.extern.packaging.utils import canonicalize_name from setuptools.extern.six import PY3 from setuptools import Distribution as SetuptoolsDistribution from setuptools import pep425tags @@ -77,14 +79,24 @@ class Wheel(object): platform=(None if self.platform == 'any' else get_platform()), ).egg_name() + '.egg' + def get_dist_info(self, zf): + # find the correct name of the .dist-info dir in the wheel file + for member in zf.namelist(): + dirname = posixpath.dirname(member) + if (dirname.endswith('.dist-info') and + canonicalize_name(dirname).startswith( + canonicalize_name(self.project_name))): + return dirname + raise ValueError("unsupported wheel format. .dist-info not found") + def install_as_egg(self, destination_eggdir): '''Install wheel as an egg directory.''' with zipfile.ZipFile(self.filename) as zf: dist_basename = '%s-%s' % (self.project_name, self.version) - dist_info = '%s.dist-info' % dist_basename + dist_info = self.get_dist_info(zf) dist_data = '%s.data' % dist_basename def get_metadata(name): - with zf.open('%s/%s' % (dist_info, name)) as fp: + 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') |