Skip to content

Commit

Permalink
Merge pull request #8611 from pradyunsg/vendoring/july-2020
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg authored Jul 23, 2020
2 parents 982aac5 + dcfea6e commit 50aca38
Show file tree
Hide file tree
Showing 80 changed files with 1,641 additions and 2,305 deletions.
1 change: 1 addition & 0 deletions news/appdirs.vendor
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade appdirs to 1.4.4
1 change: 1 addition & 0 deletions news/certifi.vendor
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade certifi to 2020.6.20
1 change: 1 addition & 0 deletions news/distlib.vendor
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade distlib to 0.3.1
1 change: 1 addition & 0 deletions news/html5lib.vendor
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade html5lib to 1.1
1 change: 1 addition & 0 deletions news/idna.vendor
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade idna to 2.10
1 change: 1 addition & 0 deletions news/packaging.vendor
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade packaging to 20.4
1 change: 1 addition & 0 deletions news/requests.vendor
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade requests to 2.24.0
1 change: 1 addition & 0 deletions news/six.vendor
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade six to 1.15.0
1 change: 1 addition & 0 deletions news/toml.vendor
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade toml to 0.10.1
1 change: 1 addition & 0 deletions news/urllib3.vendor
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade urllib3 to 1.25.9
4 changes: 2 additions & 2 deletions src/pip/_vendor/appdirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# - Mac OS X: http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/index.html
# - XDG spec for Un*x: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

__version_info__ = (1, 4, 3)
__version__ = '.'.join(map(str, __version_info__))
__version__ = "1.4.4"
__version_info__ = tuple(int(segment) for segment in __version__.split("."))


import sys
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_vendor/certifi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .core import contents, where

__version__ = "2020.04.05.1"
__version__ = "2020.06.20"
273 changes: 126 additions & 147 deletions src/pip/_vendor/certifi/cacert.pem

Large diffs are not rendered by default.

40 changes: 35 additions & 5 deletions src/pip/_vendor/certifi/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,36 @@
import os

try:
from importlib.resources import read_text
from importlib.resources import path as get_path, read_text

_CACERT_CTX = None
_CACERT_PATH = None

def where():
# This is slightly terrible, but we want to delay extracting the file
# in cases where we're inside of a zipimport situation until someone
# actually calls where(), but we don't want to re-extract the file
# on every call of where(), so we'll do it once then store it in a
# global variable.
global _CACERT_CTX
global _CACERT_PATH
if _CACERT_PATH is None:
# This is slightly janky, the importlib.resources API wants you to
# manage the cleanup of this file, so it doesn't actually return a
# path, it returns a context manager that will give you the path
# when you enter it and will do any cleanup when you leave it. In
# the common case of not needing a temporary file, it will just
# return the file system location and the __exit__() is a no-op.
#
# We also have to hold onto the actual context manager, because
# it will do the cleanup whenever it gets garbage collected, so
# we will also store that at the global level as well.
_CACERT_CTX = get_path("pip._vendor.certifi", "cacert.pem")
_CACERT_PATH = str(_CACERT_CTX.__enter__())

return _CACERT_PATH


except ImportError:
# This fallback will work for Python versions prior to 3.7 that lack the
# importlib.resources module but relies on the existing `where` function
Expand All @@ -19,11 +48,12 @@ def read_text(_module, _path, encoding="ascii"):
with open(where(), "r", encoding=encoding) as data:
return data.read()

# If we don't have importlib.resources, then we will just do the old logic
# of assuming we're on the filesystem and munge the path directly.
def where():
f = os.path.dirname(__file__)

def where():
f = os.path.dirname(__file__)

return os.path.join(f, "cacert.pem")
return os.path.join(f, "cacert.pem")


def contents():
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_vendor/distlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
import logging

__version__ = '0.3.0'
__version__ = '0.3.1'

class DistlibException(Exception):
pass
Expand Down
9 changes: 6 additions & 3 deletions src/pip/_vendor/distlib/_backport/shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
import stat
from os.path import abspath
import fnmatch
import collections
try:
from collections.abc import Callable
except ImportError:
from collections import Callable
import errno
from . import tarfile

Expand Down Expand Up @@ -528,7 +531,7 @@ def register_archive_format(name, function, extra_args=None, description=''):
"""
if extra_args is None:
extra_args = []
if not isinstance(function, collections.Callable):
if not isinstance(function, Callable):
raise TypeError('The %s object is not callable' % function)
if not isinstance(extra_args, (tuple, list)):
raise TypeError('extra_args needs to be a sequence')
Expand Down Expand Up @@ -621,7 +624,7 @@ def _check_unpack_options(extensions, function, extra_args):
raise RegistryError(msg % (extension,
existing_extensions[extension]))

if not isinstance(function, collections.Callable):
if not isinstance(function, Callable):
raise TypeError('The registered function must be a callable')


Expand Down
2 changes: 1 addition & 1 deletion src/pip/_vendor/distlib/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def python_implementation():
try:
callable = callable
except NameError: # pragma: no cover
from collections import Callable
from collections.abc import Callable

def callable(obj):
return isinstance(obj, Callable)
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_vendor/distlib/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def __init__(self, path, metadata=None, env=None):
r = finder.find(WHEEL_METADATA_FILENAME)
# Temporary - for legacy support
if r is None:
r = finder.find('METADATA')
r = finder.find(LEGACY_METADATA_FILENAME)
if r is None:
raise ValueError('no %s found in %s' % (METADATA_FILENAME,
path))
Expand Down
122 changes: 41 additions & 81 deletions src/pip/_vendor/distlib/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
"""Implementation of the Metadata for Python packages PEPs.
Supports all metadata formats (1.0, 1.1, 1.2, and 2.0 experimental).
Supports all metadata formats (1.0, 1.1, 1.2, 1.3/2.1 and withdrawn 2.0).
"""
from __future__ import unicode_literals

Expand Down Expand Up @@ -194,38 +194,12 @@ def _has_marker(keys, markers):

return '2.0'

# This follows the rules about transforming keys as described in
# https://www.python.org/dev/peps/pep-0566/#id17
_ATTR2FIELD = {
'metadata_version': 'Metadata-Version',
'name': 'Name',
'version': 'Version',
'platform': 'Platform',
'supported_platform': 'Supported-Platform',
'summary': 'Summary',
'description': 'Description',
'keywords': 'Keywords',
'home_page': 'Home-page',
'author': 'Author',
'author_email': 'Author-email',
'maintainer': 'Maintainer',
'maintainer_email': 'Maintainer-email',
'license': 'License',
'classifier': 'Classifier',
'download_url': 'Download-URL',
'obsoletes_dist': 'Obsoletes-Dist',
'provides_dist': 'Provides-Dist',
'requires_dist': 'Requires-Dist',
'setup_requires_dist': 'Setup-Requires-Dist',
'requires_python': 'Requires-Python',
'requires_external': 'Requires-External',
'requires': 'Requires',
'provides': 'Provides',
'obsoletes': 'Obsoletes',
'project_url': 'Project-URL',
'private_version': 'Private-Version',
'obsoleted_by': 'Obsoleted-By',
'extension': 'Extension',
'provides_extra': 'Provides-Extra',
name.lower().replace("-", "_"): name for name in _ALL_FIELDS
}
_FIELD2ATTR = {field: attr for attr, field in _ATTR2FIELD.items()}

_PREDICATE_FIELDS = ('Requires-Dist', 'Obsoletes-Dist', 'Provides-Dist')
_VERSIONS_FIELDS = ('Requires-Python',)
Expand Down Expand Up @@ -262,7 +236,7 @@ def _get_name_and_version(name, version, for_filename=False):
class LegacyMetadata(object):
"""The legacy metadata of a release.
Supports versions 1.0, 1.1 and 1.2 (auto-detected). You can
Supports versions 1.0, 1.1, 1.2, 2.0 and 1.3/2.1 (auto-detected). You can
instantiate the class with one of these arguments (or none):
- *path*, the path to a metadata file
- *fileobj* give a file-like object with metadata as content
Expand Down Expand Up @@ -381,6 +355,11 @@ def read_file(self, fileob):
value = msg[field]
if value is not None and value != 'UNKNOWN':
self.set(field, value)

# PEP 566 specifies that the body be used for the description, if
# available
body = msg.get_payload()
self["Description"] = body if body else self["Description"]
# logger.debug('Attempting to set metadata for %s', self)
# self.set_metadata_version()

Expand Down Expand Up @@ -567,57 +546,21 @@ def todict(self, skip_missing=False):
Field names will be converted to use the underscore-lowercase style
instead of hyphen-mixed case (i.e. home_page instead of Home-page).
This is as per https://www.python.org/dev/peps/pep-0566/#id17.
"""
self.set_metadata_version()

mapping_1_0 = (
('metadata_version', 'Metadata-Version'),
('name', 'Name'),
('version', 'Version'),
('summary', 'Summary'),
('home_page', 'Home-page'),
('author', 'Author'),
('author_email', 'Author-email'),
('license', 'License'),
('description', 'Description'),
('keywords', 'Keywords'),
('platform', 'Platform'),
('classifiers', 'Classifier'),
('download_url', 'Download-URL'),
)
fields = _version2fieldlist(self['Metadata-Version'])

data = {}
for key, field_name in mapping_1_0:

for field_name in fields:
if not skip_missing or field_name in self._fields:
data[key] = self[field_name]

if self['Metadata-Version'] == '1.2':
mapping_1_2 = (
('requires_dist', 'Requires-Dist'),
('requires_python', 'Requires-Python'),
('requires_external', 'Requires-External'),
('provides_dist', 'Provides-Dist'),
('obsoletes_dist', 'Obsoletes-Dist'),
('project_url', 'Project-URL'),
('maintainer', 'Maintainer'),
('maintainer_email', 'Maintainer-email'),
)
for key, field_name in mapping_1_2:
if not skip_missing or field_name in self._fields:
if key != 'project_url':
data[key] = self[field_name]
else:
data[key] = [','.join(u) for u in self[field_name]]

elif self['Metadata-Version'] == '1.1':
mapping_1_1 = (
('provides', 'Provides'),
('requires', 'Requires'),
('obsoletes', 'Obsoletes'),
)
for key, field_name in mapping_1_1:
if not skip_missing or field_name in self._fields:
key = _FIELD2ATTR[field_name]
if key != 'project_url':
data[key] = self[field_name]
else:
data[key] = [','.join(u) for u in self[field_name]]

return data

Expand Down Expand Up @@ -1003,10 +946,14 @@ def _from_legacy(self):
LEGACY_MAPPING = {
'name': 'Name',
'version': 'Version',
'license': 'License',
('extensions', 'python.details', 'license'): 'License',
'summary': 'Summary',
'description': 'Description',
'classifiers': 'Classifier',
('extensions', 'python.project', 'project_urls', 'Home'): 'Home-page',
('extensions', 'python.project', 'contacts', 0, 'name'): 'Author',
('extensions', 'python.project', 'contacts', 0, 'email'): 'Author-email',
'source_url': 'Download-URL',
('extensions', 'python.details', 'classifiers'): 'Classifier',
}

def _to_legacy(self):
Expand Down Expand Up @@ -1034,16 +981,29 @@ def process_entries(entries):
assert self._data and not self._legacy
result = LegacyMetadata()
nmd = self._data
# import pdb; pdb.set_trace()
for nk, ok in self.LEGACY_MAPPING.items():
if nk in nmd:
result[ok] = nmd[nk]
if not isinstance(nk, tuple):
if nk in nmd:
result[ok] = nmd[nk]
else:
d = nmd
found = True
for k in nk:
try:
d = d[k]
except (KeyError, IndexError):
found = False
break
if found:
result[ok] = d
r1 = process_entries(self.run_requires + self.meta_requires)
r2 = process_entries(self.build_requires + self.dev_requires)
if self.extras:
result['Provides-Extra'] = sorted(self.extras)
result['Requires-Dist'] = sorted(r1)
result['Setup-Requires-Dist'] = sorted(r2)
# TODO: other fields such as contacts
# TODO: any other fields wanted
return result

def write(self, path=None, fileobj=None, legacy=False, skip_unknown=True):
Expand Down
13 changes: 8 additions & 5 deletions src/pip/_vendor/distlib/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
'''


def _enquote_executable(executable):
def enquote_executable(executable):
if ' ' in executable:
# make sure we quote only the executable in case of env
# for example /usr/bin/env "/dir with spaces/bin/jython"
Expand All @@ -63,6 +63,8 @@ def _enquote_executable(executable):
executable = '"%s"' % executable
return executable

# Keep the old name around (for now), as there is at least one project using it!
_enquote_executable = enquote_executable

class ScriptMaker(object):
"""
Expand All @@ -88,6 +90,7 @@ def __init__(self, source_dir, target_dir, add_launchers=True,

self._is_nt = os.name == 'nt' or (
os.name == 'java' and os._name == 'nt')
self.version_info = sys.version_info

def _get_alternate_executable(self, executable, options):
if options.get('gui', False) and self._is_nt: # pragma: no cover
Expand Down Expand Up @@ -185,7 +188,7 @@ def _get_shebang(self, encoding, post_interp=b'', options=None):
# If the user didn't specify an executable, it may be necessary to
# cater for executable paths with spaces (not uncommon on Windows)
if enquote:
executable = _enquote_executable(executable)
executable = enquote_executable(executable)
# Issue #51: don't use fsencode, since we later try to
# check that the shebang is decodable using utf-8.
executable = executable.encode('utf-8')
Expand Down Expand Up @@ -293,10 +296,10 @@ def _make_script(self, entry, filenames, options=None):
if '' in self.variants:
scriptnames.add(name)
if 'X' in self.variants:
scriptnames.add('%s%s' % (name, sys.version_info[0]))
scriptnames.add('%s%s' % (name, self.version_info[0]))
if 'X.Y' in self.variants:
scriptnames.add('%s-%s.%s' % (name, sys.version_info[0],
sys.version_info[1]))
scriptnames.add('%s-%s.%s' % (name, self.version_info[0],
self.version_info[1]))
if options and options.get('gui', False):
ext = 'pyw'
else:
Expand Down
Loading

0 comments on commit 50aca38

Please sign in to comment.