diff --git a/news/distlib.vendor b/news/distlib.vendor new file mode 100644 index 0000000000000000000000000000000000000000..97fcc1a476d35e8110be9e79465ade24f25f37c4 --- /dev/null +++ b/news/distlib.vendor @@ -0,0 +1 @@ +Upgrade distlib to 0.2.7 diff --git a/src/pip/_vendor/distlib/__init__.py b/src/pip/_vendor/distlib/__init__.py index 718b9879a446064a207f79a57a7502f78c69595a..d4aab453aefd62a866be23942cfd23bb4a5f88a0 100644 --- a/src/pip/_vendor/distlib/__init__.py +++ b/src/pip/_vendor/distlib/__init__.py @@ -6,7 +6,7 @@ # import logging -__version__ = '0.2.6' +__version__ = '0.2.7' class DistlibException(Exception): pass diff --git a/src/pip/_vendor/distlib/compat.py b/src/pip/_vendor/distlib/compat.py index 9387cdada63228c5e9eae26da03edf3641f31407..ff328c8ee491f9f3c943cf637dc7ea17ea33ee3b 100644 --- a/src/pip/_vendor/distlib/compat.py +++ b/src/pip/_vendor/distlib/compat.py @@ -614,17 +614,20 @@ except ImportError: # pragma: no cover self.maps[0].clear() try: - from imp import cache_from_source -except ImportError: # pragma: no cover - def cache_from_source(path, debug_override=None): - assert path.endswith('.py') - if debug_override is None: - debug_override = __debug__ - if debug_override: - suffix = 'c' - else: - suffix = 'o' - return path + suffix + from importlib.util import cache_from_source # Python >= 3.4 +except ImportError: # pragma: no cover + try: + from imp import cache_from_source + except ImportError: # pragma: no cover + def cache_from_source(path, debug_override=None): + assert path.endswith('.py') + if debug_override is None: + debug_override = __debug__ + if debug_override: + suffix = 'c' + else: + suffix = 'o' + return path + suffix try: from collections import OrderedDict diff --git a/src/pip/_vendor/distlib/database.py b/src/pip/_vendor/distlib/database.py index 75bb5edaf5522fccb42412a5c00ab11addf88f13..a19905e2151e0ff2f5d796b49b5f06ff8c6e0681 100644 --- a/src/pip/_vendor/distlib/database.py +++ b/src/pip/_vendor/distlib/database.py @@ -534,9 +534,10 @@ class InstalledDistribution(BaseInstalledDistribution): hasher = 'sha256' def __init__(self, path, metadata=None, env=None): + self.modules = [] self.finder = finder = resources.finder_for_path(path) if finder is None: - import pdb; pdb.set_trace () + raise ValueError('finder unavailable for %s' % path) if env and env._cache_enabled and path in env._cache.path: metadata = env._cache.path[path].metadata elif metadata is None: @@ -558,11 +559,13 @@ class InstalledDistribution(BaseInstalledDistribution): if env and env._cache_enabled: env._cache.add(self) - try: - r = finder.find('REQUESTED') - except AttributeError: - import pdb; pdb.set_trace () + r = finder.find('REQUESTED') self.requested = r is not None + p = os.path.join(path, 'top_level.txt') + if os.path.exists(p): + with open(p, 'rb') as f: + data = f.read() + self.modules = data.splitlines() def __repr__(self): return '' % ( @@ -922,11 +925,14 @@ class EggInfoDistribution(BaseInstalledDistribution): pass return reqs + tl_path = tl_data = None if path.endswith('.egg'): if os.path.isdir(path): - meta_path = os.path.join(path, 'EGG-INFO', 'PKG-INFO') + p = os.path.join(path, 'EGG-INFO') + meta_path = os.path.join(p, 'PKG-INFO') metadata = Metadata(path=meta_path, scheme='legacy') - req_path = os.path.join(path, 'EGG-INFO', 'requires.txt') + req_path = os.path.join(p, 'requires.txt') + tl_path = os.path.join(p, 'top_level.txt') requires = parse_requires_path(req_path) else: # FIXME handle the case where zipfile is not available @@ -936,6 +942,7 @@ class EggInfoDistribution(BaseInstalledDistribution): metadata = Metadata(fileobj=fileobj, scheme='legacy') try: data = zipf.get_data('EGG-INFO/requires.txt') + tl_data = zipf.get_data('EGG-INFO/top_level.txt').decode('utf-8') requires = parse_requires_data(data.decode('utf-8')) except IOError: requires = None @@ -944,6 +951,7 @@ class EggInfoDistribution(BaseInstalledDistribution): req_path = os.path.join(path, 'requires.txt') requires = parse_requires_path(req_path) path = os.path.join(path, 'PKG-INFO') + tl_path = os.path.join(path, 'top_level.txt') metadata = Metadata(path=path, scheme='legacy') else: raise DistlibException('path must end with .egg-info or .egg, ' @@ -951,6 +959,16 @@ class EggInfoDistribution(BaseInstalledDistribution): if requires: metadata.add_requirements(requires) + # look for top-level modules in top_level.txt, if present + if tl_data is None: + if tl_path is not None and os.path.exists(tl_path): + with open(tl_path, 'rb') as f: + tl_data = f.read().decode('utf-8') + if not tl_data: + tl_data = [] + else: + tl_data = tl_data.splitlines() + self.modules = tl_data return metadata def __repr__(self): diff --git a/src/pip/_vendor/distlib/locators.py b/src/pip/_vendor/distlib/locators.py index e68a4c98f56dd73858a7805e19764acb94ba0873..11d26361c90b6173349286fbe0297c42d24db134 100644 --- a/src/pip/_vendor/distlib/locators.py +++ b/src/pip/_vendor/distlib/locators.py @@ -197,7 +197,7 @@ class Locator(object): is_downloadable = basename.endswith(self.downloadable_extensions) if is_wheel: compatible = is_compatible(Wheel(basename), self.wheel_tags) - return (t.scheme != 'https', 'pypi.python.org' in t.netloc, + return (t.scheme == 'https', 'pypi.python.org' in t.netloc, is_downloadable, is_wheel, compatible, basename) def prefer_url(self, url1, url2): diff --git a/src/pip/_vendor/distlib/metadata.py b/src/pip/_vendor/distlib/metadata.py index cbf1976621acc81b22231d26971f4c0f5e2e5c56..6d6470fff8b00628b649a146bfaf77460e5081f0 100644 --- a/src/pip/_vendor/distlib/metadata.py +++ b/src/pip/_vendor/distlib/metadata.py @@ -91,11 +91,16 @@ _426_FIELDS = ('Metadata-Version', 'Name', 'Version', 'Platform', _426_MARKERS = ('Private-Version', 'Provides-Extra', 'Obsoleted-By', 'Setup-Requires-Dist', 'Extension') +_566_FIELDS = _426_FIELDS + ('Description-Content-Type',) + +_566_MARKERS = ('Description-Content-Type',) + _ALL_FIELDS = set() _ALL_FIELDS.update(_241_FIELDS) _ALL_FIELDS.update(_314_FIELDS) _ALL_FIELDS.update(_345_FIELDS) _ALL_FIELDS.update(_426_FIELDS) +_ALL_FIELDS.update(_566_FIELDS) EXTRA_RE = re.compile(r'''extra\s*==\s*("([^"]+)"|'([^']+)')''') @@ -107,6 +112,8 @@ def _version2fieldlist(version): return _314_FIELDS elif version == '1.2': return _345_FIELDS + elif version in ('1.3', '2.1'): + return _345_FIELDS + _566_FIELDS elif version == '2.0': return _426_FIELDS raise MetadataUnrecognizedVersionError(version) @@ -126,38 +133,51 @@ def _best_version(fields): continue keys.append(key) - possible_versions = ['1.0', '1.1', '1.2', '2.0'] + possible_versions = ['1.0', '1.1', '1.2', '1.3', '2.0', '2.1'] # first let's try to see if a field is not part of one of the version for key in keys: if key not in _241_FIELDS and '1.0' in possible_versions: possible_versions.remove('1.0') + logger.debug('Removed 1.0 due to %s', key) if key not in _314_FIELDS and '1.1' in possible_versions: possible_versions.remove('1.1') + logger.debug('Removed 1.1 due to %s', key) if key not in _345_FIELDS and '1.2' in possible_versions: possible_versions.remove('1.2') + logger.debug('Removed 1.2 due to %s', key) + if key not in _566_FIELDS and '1.3' in possible_versions: + possible_versions.remove('1.3') + logger.debug('Removed 1.3 due to %s', key) + if key not in _566_FIELDS and '2.1' in possible_versions: + if key != 'Description': # In 2.1, description allowed after headers + possible_versions.remove('2.1') + logger.debug('Removed 2.1 due to %s', key) if key not in _426_FIELDS and '2.0' in possible_versions: possible_versions.remove('2.0') + logger.debug('Removed 2.0 due to %s', key) # possible_version contains qualified versions if len(possible_versions) == 1: return possible_versions[0] # found ! elif len(possible_versions) == 0: + logger.debug('Out of options - unknown metadata set: %s', fields) raise MetadataConflictError('Unknown metadata set') # let's see if one unique marker is found is_1_1 = '1.1' in possible_versions and _has_marker(keys, _314_MARKERS) is_1_2 = '1.2' in possible_versions and _has_marker(keys, _345_MARKERS) + is_2_1 = '2.1' in possible_versions and _has_marker(keys, _566_MARKERS) is_2_0 = '2.0' in possible_versions and _has_marker(keys, _426_MARKERS) - if int(is_1_1) + int(is_1_2) + int(is_2_0) > 1: - raise MetadataConflictError('You used incompatible 1.1/1.2/2.0 fields') + if int(is_1_1) + int(is_1_2) + int(is_2_1) + int(is_2_0) > 1: + raise MetadataConflictError('You used incompatible 1.1/1.2/2.0/2.1 fields') # we have the choice, 1.0, or 1.2, or 2.0 # - 1.0 has a broken Summary field but works with all tools # - 1.1 is to avoid # - 1.2 fixes Summary but has little adoption # - 2.0 adds more features and is very new - if not is_1_1 and not is_1_2 and not is_2_0: + if not is_1_1 and not is_1_2 and not is_2_1 and not is_2_0: # we couldn't find any specific marker if PKG_INFO_PREFERRED_VERSION in possible_versions: return PKG_INFO_PREFERRED_VERSION @@ -165,6 +185,8 @@ def _best_version(fields): return '1.1' if is_1_2: return '1.2' + if is_2_1: + return '2.1' return '2.0' @@ -355,6 +377,7 @@ class LegacyMetadata(object): value = msg[field] if value is not None and value != 'UNKNOWN': self.set(field, value) + logger.debug('Attempting to set metadata for %s', self) self.set_metadata_version() def write(self, filepath, skip_unknown=False): diff --git a/src/pip/_vendor/distlib/t32.exe b/src/pip/_vendor/distlib/t32.exe index bd14c7a627e1055708739fdc9635fba15c3d91ea..a09d926872d84ae22a617dfe9ebb560d420b37de 100644 Binary files a/src/pip/_vendor/distlib/t32.exe and b/src/pip/_vendor/distlib/t32.exe differ diff --git a/src/pip/_vendor/distlib/t64.exe b/src/pip/_vendor/distlib/t64.exe index cb6db26b42e96eb2d415389e7f5c2975c525b8c4..9da9b40de922fb203df6b9a1d0ad4139af536850 100644 Binary files a/src/pip/_vendor/distlib/t64.exe and b/src/pip/_vendor/distlib/t64.exe differ diff --git a/src/pip/_vendor/distlib/w32.exe b/src/pip/_vendor/distlib/w32.exe index 9652c917d581b5b9ddf90766595b7701710fe875..732215a9d34ccb7b417d637a7646d9b843ecafa8 100644 Binary files a/src/pip/_vendor/distlib/w32.exe and b/src/pip/_vendor/distlib/w32.exe differ diff --git a/src/pip/_vendor/distlib/w64.exe b/src/pip/_vendor/distlib/w64.exe index ec2dc656896831df135b3fcc9c4f1cb8f842992b..c41bd0a011fd760ce20ba795d9e535e0d2c39876 100644 Binary files a/src/pip/_vendor/distlib/w64.exe and b/src/pip/_vendor/distlib/w64.exe differ diff --git a/src/pip/_vendor/vendor.txt b/src/pip/_vendor/vendor.txt index bd81d9a00b4e63f0feaad4119aede049a3712bf5..4a937e8d72e1eaf45b5df432f5837f6fb97e5642 100644 --- a/src/pip/_vendor/vendor.txt +++ b/src/pip/_vendor/vendor.txt @@ -1,5 +1,5 @@ appdirs==1.4.3 -distlib==0.2.6 +distlib==0.2.7 distro==1.2.0 html5lib==1.0.1 six==1.11.0