Skip to content

Commit

Permalink
Merge pull request #4819 from pradyunsg/vendoring/late-oct-2017
Browse files Browse the repository at this point in the history
* Update distlib to 0.2.6
* Update six to 1.11.0
* Update pkg_resources (via setuptools) to 36.6.0.
  • Loading branch information
pradyunsg authored Nov 3, 2017
2 parents 288a10b + 058f3b6 commit 87d2735
Show file tree
Hide file tree
Showing 19 changed files with 267 additions and 124 deletions.
2 changes: 1 addition & 1 deletion news/distlib.vendor
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Upgraded distlib to 0.2.5.
Upgraded distlib to 0.2.6.
2 changes: 1 addition & 1 deletion news/setuptools.vendor
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Upgraded pkg_resources (via setuptools) to 36.4.0.
Upgraded pkg_resources (via setuptools) to 36.6.0.
1 change: 1 addition & 0 deletions news/six.vendor
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgraded six to 1.11.0.
4 changes: 2 additions & 2 deletions src/pip/_vendor/distlib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2012-2016 Vinay Sajip.
# Copyright (C) 2012-2017 Vinay Sajip.
# Licensed to the Python Software Foundation under a contributor agreement.
# See LICENSE.txt and CONTRIBUTORS.txt.
#
import logging

__version__ = '0.2.5'
__version__ = '0.2.6'

class DistlibException(Exception):
pass
Expand Down
14 changes: 10 additions & 4 deletions src/pip/_vendor/distlib/compat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2013-2016 Vinay Sajip.
# Copyright (C) 2013-2017 Vinay Sajip.
# Licensed to the Python Software Foundation under a contributor agreement.
# See LICENSE.txt and CONTRIBUTORS.txt.
#
Expand All @@ -12,7 +12,7 @@

try:
import ssl
except ImportError:
except ImportError: # pragma: no cover
ssl = None

if sys.version_info[0] < 3: # pragma: no cover
Expand Down Expand Up @@ -272,7 +272,7 @@ def _access_check(fn, mode):

if hasattr(BaseZipFile, '__enter__'): # pragma: no cover
ZipFile = BaseZipFile
else:
else: # pragma: no cover
from zipfile import ZipExtFile as BaseZipExtFile

class ZipExtFile(BaseZipExtFile):
Expand Down Expand Up @@ -329,7 +329,13 @@ def callable(obj):
fsencode = os.fsencode
fsdecode = os.fsdecode
except AttributeError: # pragma: no cover
_fsencoding = sys.getfilesystemencoding()
# Issue #99: on some systems (e.g. containerised),
# sys.getfilesystemencoding() returns None, and we need a real value,
# so fall back to utf-8. From the CPython 2.7 docs relating to Unix and
# sys.getfilesystemencoding(): the return value is "the user’s preference
# according to the result of nl_langinfo(CODESET), or None if the
# nl_langinfo(CODESET) failed."
_fsencoding = sys.getfilesystemencoding() or 'utf-8'
if _fsencoding == 'mbcs':
_fserrors = 'strict'
else:
Expand Down
58 changes: 32 additions & 26 deletions src/pip/_vendor/distlib/database.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2012-2016 The Python Software Foundation.
# Copyright (C) 2012-2017 The Python Software Foundation.
# See LICENSE.txt and CONTRIBUTORS.txt.
#
"""PEP 376 implementation."""
Expand Down Expand Up @@ -265,18 +265,23 @@ def provides_distribution(self, name, version=None):
(name, version))

for dist in self.get_distributions():
provided = dist.provides
# We hit a problem on Travis where enum34 was installed and doesn't
# have a provides attribute ...
if not hasattr(dist, 'provides'):
logger.debug('No "provides": %s', dist)
else:
provided = dist.provides

for p in provided:
p_name, p_ver = parse_name_and_version(p)
if matcher is None:
if p_name == name:
yield dist
break
else:
if p_name == name and matcher.match(p_ver):
yield dist
break
for p in provided:
p_name, p_ver = parse_name_and_version(p)
if matcher is None:
if p_name == name:
yield dist
break
else:
if p_name == name and matcher.match(p_ver):
yield dist
break

def get_file_path(self, name, relative_path):
"""
Expand Down Expand Up @@ -1025,20 +1030,21 @@ def list_distinfo_files(self, absolute=False):
:returns: iterator of paths
"""
record_path = os.path.join(self.path, 'installed-files.txt')
skip = True
with codecs.open(record_path, 'r', encoding='utf-8') as f:
for line in f:
line = line.strip()
if line == './':
skip = False
continue
if not skip:
p = os.path.normpath(os.path.join(self.path, line))
if p.startswith(self.path):
if absolute:
yield p
else:
yield line
if os.path.exists(record_path):
skip = True
with codecs.open(record_path, 'r', encoding='utf-8') as f:
for line in f:
line = line.strip()
if line == './':
skip = False
continue
if not skip:
p = os.path.normpath(os.path.join(self.path, line))
if p.startswith(self.path):
if absolute:
yield p
else:
yield line

def __eq__(self, other):
return (isinstance(other, EggInfoDistribution) and
Expand Down
35 changes: 20 additions & 15 deletions src/pip/_vendor/distlib/locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
HTTPRedirectHandler as BaseRedirectHandler, text_type,
Request, HTTPError, URLError)
from .database import Distribution, DistributionPath, make_dist
from .metadata import Metadata
from .metadata import Metadata, MetadataInvalidError
from .util import (cached_property, parse_credentials, ensure_slash,
split_filename, get_project_data, parse_requirement,
parse_name_and_version, ServerProxy, normalize_name)
Expand Down Expand Up @@ -69,7 +69,7 @@ def http_error_302(self, req, fp, code, msg, headers):
if key in headers:
newurl = headers[key]
break
if newurl is None:
if newurl is None: # pragma: no cover
return
urlparts = urlparse(newurl)
if urlparts.scheme == '':
Expand Down Expand Up @@ -175,7 +175,7 @@ def get_project(self, name):
This calls _get_project to do all the work, and just implements a caching layer on top.
"""
if self._cache is None:
if self._cache is None: # pragma: no cover
result = self._get_project(name)
elif name in self._cache:
result = self._cache[name]
Expand Down Expand Up @@ -241,7 +241,7 @@ def same_project(name1, name2):

result = None
scheme, netloc, path, params, query, frag = urlparse(url)
if frag.lower().startswith('egg='):
if frag.lower().startswith('egg='): # pragma: no cover
logger.debug('%s: version hint in fragment: %r',
project_name, frag)
m = HASHER_HASH.match(frag)
Expand All @@ -250,7 +250,7 @@ def same_project(name1, name2):
else:
algo, digest = None, None
origpath = path
if path and path[-1] == '/':
if path and path[-1] == '/': # pragma: no cover
path = path[:-1]
if path.endswith('.whl'):
try:
Expand All @@ -272,13 +272,15 @@ def same_project(name1, name2):
}
except Exception as e: # pragma: no cover
logger.warning('invalid path for wheel: %s', path)
elif path.endswith(self.downloadable_extensions):
elif not path.endswith(self.downloadable_extensions): # pragma: no cover
logger.debug('Not downloadable: %s', path)
else: # downloadable extension
path = filename = posixpath.basename(path)
for ext in self.downloadable_extensions:
if path.endswith(ext):
path = path[:-len(ext)]
t = self.split_filename(path, project_name)
if not t:
if not t: # pragma: no cover
logger.debug('No match for project/version: %s', path)
else:
name, version, pyver = t
Expand All @@ -291,7 +293,7 @@ def same_project(name1, name2):
params, query, '')),
#'packagetype': 'sdist',
}
if pyver:
if pyver: # pragma: no cover
result['python-version'] = pyver
break
if result and algo:
Expand Down Expand Up @@ -352,7 +354,7 @@ def locate(self, requirement, prereleases=False):
"""
result = None
r = parse_requirement(requirement)
if r is None:
if r is None: # pragma: no cover
raise DistlibException('Not a valid requirement: %r' % requirement)
scheme = get_scheme(self.scheme)
self.matcher = matcher = scheme.matcher(r.requirement)
Expand Down Expand Up @@ -390,7 +392,7 @@ def locate(self, requirement, prereleases=False):
d = {}
sd = versions.get('digests', {})
for url in result.download_urls:
if url in sd:
if url in sd: # pragma: no cover
d[url] = sd[url]
result.digests = d
self.matcher = None
Expand Down Expand Up @@ -730,11 +732,14 @@ def _fetch(self):
continue
for link, rel in page.links:
if link not in self._seen:
self._seen.add(link)
if (not self._process_download(link) and
self._should_queue(link, url, rel)):
logger.debug('Queueing %s from %s', link, url)
self._to_fetch.put(link)
try:
self._seen.add(link)
if (not self._process_download(link) and
self._should_queue(link, url, rel)):
logger.debug('Queueing %s from %s', link, url)
self._to_fetch.put(link)
except MetadataInvalidError: # e.g. invalid versions
pass
except Exception as e: # pragma: no cover
self.errors.put(text_type(e))
finally:
Expand Down
7 changes: 5 additions & 2 deletions src/pip/_vendor/distlib/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,12 @@ def interpret(marker, execution_context=None):
:param execution_context: The context used for name lookup.
:type execution_context: mapping
"""
expr, rest = parse_marker(marker)
try:
expr, rest = parse_marker(marker)
except Exception as e:
raise SyntaxError('Unable to interpret marker syntax: %s: %s' % (marker, e))
if rest and rest[0] != '#':
raise SyntaxError('unexpected trailing data: %s' % rest)
raise SyntaxError('unexpected trailing data in marker: %s: %s' % (marker, rest))
context = dict(DEFAULT_CONTEXT)
if execution_context:
context.update(execution_context)
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_vendor/distlib/resources.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2013-2016 Vinay Sajip.
# Copyright (C) 2013-2017 Vinay Sajip.
# Licensed to the Python Software Foundation under a contributor agreement.
# See LICENSE.txt and CONTRIBUTORS.txt.
#
Expand Down
33 changes: 32 additions & 1 deletion src/pip/_vendor/distlib/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,37 @@ def _fix_jython_executable(self, executable):
return executable
return '/usr/bin/env %s' % executable

def _build_shebang(self, executable, post_interp):
"""
Build a shebang line. In the simple case (on Windows, or a shebang line
which is not too long or contains spaces) use a simple formulation for
the shebang. Otherwise, use /bin/sh as the executable, with a contrived
shebang which allows the script to run either under Python or sh, using
suitable quoting. Thanks to Harald Nordgren for his input.
See also: http://www.in-ulm.de/~mascheck/various/shebang/#length
https://hg.mozilla.org/mozilla-central/file/tip/mach
"""
if os.name != 'posix':
simple_shebang = True
else:
# Add 3 for '#!' prefix and newline suffix.
shebang_length = len(executable) + len(post_interp) + 3
if sys.platform == 'darwin':
max_shebang_length = 512
else:
max_shebang_length = 127
simple_shebang = ((b' ' not in executable) and
(shebang_length <= max_shebang_length))

if simple_shebang:
result = b'#!' + executable + post_interp + b'\n'
else:
result = b'#!/bin/sh\n'
result += b"'''exec' " + executable + post_interp + b' "$0" "$@"\n'
result += b"' '''"
return result

def _get_shebang(self, encoding, post_interp=b'', options=None):
enquote = True
if self.executable:
Expand Down Expand Up @@ -169,7 +200,7 @@ def _get_shebang(self, encoding, post_interp=b'', options=None):
if (sys.platform == 'cli' and '-X:Frames' not in post_interp
and '-X:FullFrames' not in post_interp): # pragma: no cover
post_interp += b' -X:Frames'
shebang = b'#!' + executable + post_interp + b'\n'
shebang = self._build_shebang(executable, post_interp)
# Python parser starts to read a script using UTF-8 until
# it gets a #coding:xxx cookie. The shebang has to be the
# first line of a file, the #coding:xxx cookie cannot be
Expand Down
Binary file modified src/pip/_vendor/distlib/t32.exe
Binary file not shown.
Binary file modified src/pip/_vendor/distlib/t64.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion src/pip/_vendor/distlib/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2012-2016 The Python Software Foundation.
# Copyright (C) 2012-2017 The Python Software Foundation.
# See LICENSE.txt and CONTRIBUTORS.txt.
#
"""
Expand Down
Binary file modified src/pip/_vendor/distlib/w32.exe
Binary file not shown.
Binary file modified src/pip/_vendor/distlib/w64.exe
Binary file not shown.
8 changes: 4 additions & 4 deletions src/pip/_vendor/distlib/wheel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2013-2016 Vinay Sajip.
# Copyright (C) 2013-2017 Vinay Sajip.
# Licensed to the Python Software Foundation under a contributor agreement.
# See LICENSE.txt and CONTRIBUTORS.txt.
#
Expand Down Expand Up @@ -35,11 +35,11 @@

cache = None # created when needed

if hasattr(sys, 'pypy_version_info'):
if hasattr(sys, 'pypy_version_info'): # pragma: no cover
IMP_PREFIX = 'pp'
elif sys.platform.startswith('java'):
elif sys.platform.startswith('java'): # pragma: no cover
IMP_PREFIX = 'jy'
elif sys.platform == 'cli':
elif sys.platform == 'cli': # pragma: no cover
IMP_PREFIX = 'ip'
else:
IMP_PREFIX = 'cp'
Expand Down
Loading

0 comments on commit 87d2735

Please sign in to comment.