Skip to content

Commit 1c4753f

Browse files
authored
Vendoring update for 21.2 (#10179)
1 parent 6af7739 commit 1c4753f

31 files changed

+833
-503
lines changed

src/pip/_vendor/distlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
import logging
88

9-
__version__ = '0.3.1'
9+
__version__ = '0.3.2'
1010

1111
class DistlibException(Exception):
1212
pass

src/pip/_vendor/distlib/index.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from . import DistlibException
1919
from .compat import (HTTPBasicAuthHandler, Request, HTTPPasswordMgr,
2020
urlparse, build_opener, string_types)
21-
from .util import cached_property, zip_dir, ServerProxy
21+
from .util import zip_dir, ServerProxy
2222

2323
logger = logging.getLogger(__name__)
2424

@@ -67,21 +67,17 @@ def _get_pypirc_command(self):
6767
Get the distutils command for interacting with PyPI configurations.
6868
:return: the command.
6969
"""
70-
from distutils.core import Distribution
71-
from distutils.config import PyPIRCCommand
72-
d = Distribution()
73-
return PyPIRCCommand(d)
70+
from .util import _get_pypirc_command as cmd
71+
return cmd()
7472

7573
def read_configuration(self):
7674
"""
77-
Read the PyPI access configuration as supported by distutils, getting
78-
PyPI to do the actual work. This populates ``username``, ``password``,
79-
``realm`` and ``url`` attributes from the configuration.
75+
Read the PyPI access configuration as supported by distutils. This populates
76+
``username``, ``password``, ``realm`` and ``url`` attributes from the
77+
configuration.
8078
"""
81-
# get distutils to do the work
82-
c = self._get_pypirc_command()
83-
c.repository = self.url
84-
cfg = c._read_pypirc()
79+
from .util import _load_pypirc
80+
cfg = _load_pypirc(self)
8581
self.username = cfg.get('username')
8682
self.password = cfg.get('password')
8783
self.realm = cfg.get('realm', 'pypi')
@@ -91,13 +87,10 @@ def save_configuration(self):
9187
"""
9288
Save the PyPI access configuration. You must have set ``username`` and
9389
``password`` attributes before calling this method.
94-
95-
Again, distutils is used to do the actual work.
9690
"""
9791
self.check_credentials()
98-
# get distutils to do the work
99-
c = self._get_pypirc_command()
100-
c._store_pypirc(self.username, self.password)
92+
from .util import _store_pypirc
93+
_store_pypirc(self)
10194

10295
def check_credentials(self):
10396
"""

src/pip/_vendor/distlib/locators.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020

2121
from . import DistlibException
2222
from .compat import (urljoin, urlparse, urlunparse, url2pathname, pathname2url,
23-
queue, quote, unescape, string_types, build_opener,
23+
queue, quote, unescape, build_opener,
2424
HTTPRedirectHandler as BaseRedirectHandler, text_type,
2525
Request, HTTPError, URLError)
2626
from .database import Distribution, DistributionPath, make_dist
2727
from .metadata import Metadata, MetadataInvalidError
28-
from .util import (cached_property, parse_credentials, ensure_slash,
29-
split_filename, get_project_data, parse_requirement,
30-
parse_name_and_version, ServerProxy, normalize_name)
28+
from .util import (cached_property, ensure_slash, split_filename, get_project_data,
29+
parse_requirement, parse_name_and_version, ServerProxy,
30+
normalize_name)
3131
from .version import get_scheme, UnsupportedVersionError
3232
from .wheel import Wheel, is_compatible
3333

@@ -378,13 +378,13 @@ def locate(self, requirement, prereleases=False):
378378
continue
379379
try:
380380
if not matcher.match(k):
381-
logger.debug('%s did not match %r', matcher, k)
381+
pass # logger.debug('%s did not match %r', matcher, k)
382382
else:
383383
if prereleases or not vcls(k).is_prerelease:
384384
slist.append(k)
385-
else:
386-
logger.debug('skipping pre-release '
387-
'version %s of %s', k, matcher.name)
385+
# else:
386+
# logger.debug('skipping pre-release '
387+
# 'version %s of %s', k, matcher.name)
388388
except Exception: # pragma: no cover
389389
logger.warning('error matching %s with %r', matcher, k)
390390
pass # slist.append(k)
@@ -593,7 +593,7 @@ class SimpleScrapingLocator(Locator):
593593
# These are used to deal with various Content-Encoding schemes.
594594
decoders = {
595595
'deflate': zlib.decompress,
596-
'gzip': lambda b: gzip.GzipFile(fileobj=BytesIO(d)).read(),
596+
'gzip': lambda b: gzip.GzipFile(fileobj=BytesIO(b)).read(),
597597
'none': lambda b: b,
598598
}
599599

@@ -1062,8 +1062,6 @@ def get_distribution_names(self):
10621062

10631063
locate = default_locator.locate
10641064

1065-
NAME_VERSION_RE = re.compile(r'(?P<name>[\w-]+)\s*'
1066-
r'\(\s*(==\s*)?(?P<ver>[^)]+)\)$')
10671065

10681066
class DependencyFinder(object):
10691067
"""

src/pip/_vendor/distlib/markers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
import os
1616
import sys
1717
import platform
18-
import re
1918

20-
from .compat import python_implementation, urlparse, string_types
19+
from .compat import string_types
2120
from .util import in_venv, parse_marker
2221

2322
__all__ = ['interpret']

src/pip/_vendor/distlib/metadata.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ class MetadataInvalidError(DistlibException):
9494
# See issue #106: Sometimes 'Requires' and 'Provides' occur wrongly in
9595
# the metadata. Include them in the tuple literal below to allow them
9696
# (for now).
97+
# Ditto for Obsoletes - see issue #140.
9798
_566_FIELDS = _426_FIELDS + ('Description-Content-Type',
98-
'Requires', 'Provides')
99+
'Requires', 'Provides', 'Obsoletes')
99100

100101
_566_MARKERS = ('Description-Content-Type',)
101102

@@ -117,7 +118,8 @@ def _version2fieldlist(version):
117118
elif version == '1.2':
118119
return _345_FIELDS
119120
elif version in ('1.3', '2.1'):
120-
return _345_FIELDS + _566_FIELDS
121+
# avoid adding field names if already there
122+
return _345_FIELDS + tuple(f for f in _566_FIELDS if f not in _345_FIELDS)
121123
elif version == '2.0':
122124
return _426_FIELDS
123125
raise MetadataUnrecognizedVersionError(version)

src/pip/_vendor/distlib/resources.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
import logging
1212
import os
1313
import pkgutil
14-
import shutil
1514
import sys
1615
import types
1716
import zipimport
1817

1918
from . import DistlibException
20-
from .util import cached_property, get_cache_base, path_to_cache_dir, Cache
19+
from .util import cached_property, get_cache_base, Cache
2120

2221
logger = logging.getLogger(__name__)
2322

@@ -283,6 +282,7 @@ def _is_directory(self, path):
283282
result = False
284283
return result
285284

285+
286286
_finder_registry = {
287287
type(None): ResourceFinder,
288288
zipimport.zipimporter: ZipResourceFinder
@@ -296,6 +296,8 @@ def _is_directory(self, path):
296296
import _frozen_importlib as _fi
297297
_finder_registry[_fi.SourceFileLoader] = ResourceFinder
298298
_finder_registry[_fi.FileFinder] = ResourceFinder
299+
# See issue #146
300+
_finder_registry[_fi.SourcelessFileLoader] = ResourceFinder
299301
del _fi
300302
except (ImportError, AttributeError):
301303
pass
@@ -304,6 +306,7 @@ def _is_directory(self, path):
304306
def register_finder(loader, finder_maker):
305307
_finder_registry[type(loader)] = finder_maker
306308

309+
307310
_finder_cache = {}
308311

309312

src/pip/_vendor/distlib/scripts.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,19 @@ def _write_script(self, names, shebang, script_bytes, filenames, ext):
282282
self._fileop.set_executable_mode([outname])
283283
filenames.append(outname)
284284

285+
variant_separator = '-'
286+
287+
def get_script_filenames(self, name):
288+
result = set()
289+
if '' in self.variants:
290+
result.add(name)
291+
if 'X' in self.variants:
292+
result.add('%s%s' % (name, self.version_info[0]))
293+
if 'X.Y' in self.variants:
294+
result.add('%s%s%s.%s' % (name, self.variant_separator,
295+
self.version_info[0], self.version_info[1]))
296+
return result
297+
285298
def _make_script(self, entry, filenames, options=None):
286299
post_interp = b''
287300
if options:
@@ -291,15 +304,7 @@ def _make_script(self, entry, filenames, options=None):
291304
post_interp = args.encode('utf-8')
292305
shebang = self._get_shebang('utf-8', post_interp, options=options)
293306
script = self._get_script_text(entry).encode('utf-8')
294-
name = entry.name
295-
scriptnames = set()
296-
if '' in self.variants:
297-
scriptnames.add(name)
298-
if 'X' in self.variants:
299-
scriptnames.add('%s%s' % (name, self.version_info[0]))
300-
if 'X.Y' in self.variants:
301-
scriptnames.add('%s-%s.%s' % (name, self.version_info[0],
302-
self.version_info[1]))
307+
scriptnames = self.get_script_filenames(entry.name)
303308
if options and options.get('gui', False):
304309
ext = 'pyw'
305310
else:
@@ -326,8 +331,7 @@ def _copy_script(self, script, filenames):
326331
else:
327332
first_line = f.readline()
328333
if not first_line: # pragma: no cover
329-
logger.warning('%s: %s is an empty file (skipping)',
330-
self.get_command_name(), script)
334+
logger.warning('%s is an empty file (skipping)', script)
331335
return
332336

333337
match = FIRST_LINE_RE.match(first_line.replace(b'\r\n', b'\n'))

0 commit comments

Comments
 (0)