Skip to content

Commit cb66b03

Browse files
niyas-saitNiyas Sait
andauthored
Upgrade distlib to 0.3.3 (#10502)
Co-authored-by: Niyas Sait <[email protected]>
1 parent b392833 commit cb66b03

File tree

12 files changed

+56
-22
lines changed

12 files changed

+56
-22
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Upgrade distlib to 0.3.3

setup.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,14 @@ def get_version(rel_path: str) -> str:
6464
"pip._vendor.certifi": ["*.pem"],
6565
"pip._vendor.requests": ["*.pem"],
6666
"pip._vendor.distlib._backport": ["sysconfig.cfg"],
67-
"pip._vendor.distlib": ["t32.exe", "t64.exe", "w32.exe", "w64.exe"],
67+
"pip._vendor.distlib": [
68+
"t32.exe",
69+
"t64.exe",
70+
"t64-arm.exe",
71+
"w32.exe",
72+
"w64.exe",
73+
"w64-arm.exe",
74+
],
6875
},
6976
entry_points={
7077
"console_scripts": [

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.2'
9+
__version__ = '0.3.3'
1010

1111
class DistlibException(Exception):
1212
pass

src/pip/_vendor/distlib/compat.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,18 @@ def quote(s):
4848
from itertools import ifilter as filter
4949
from itertools import ifilterfalse as filterfalse
5050

51-
_userprog = None
52-
def splituser(host):
53-
"""splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'."""
54-
global _userprog
55-
if _userprog is None:
56-
import re
57-
_userprog = re.compile('^(.*)@(.*)$')
58-
59-
match = _userprog.match(host)
60-
if match: return match.group(1, 2)
61-
return None, host
51+
# Leaving this around for now, in case it needs resurrecting in some way
52+
# _userprog = None
53+
# def splituser(host):
54+
# """splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'."""
55+
# global _userprog
56+
# if _userprog is None:
57+
# import re
58+
# _userprog = re.compile('^(.*)@(.*)$')
59+
60+
# match = _userprog.match(host)
61+
# if match: return match.group(1, 2)
62+
# return None, host
6263

6364
else: # pragma: no cover
6465
from io import StringIO
@@ -68,7 +69,7 @@ def splituser(host):
6869
import builtins
6970
import configparser
7071
import shutil
71-
from urllib.parse import (urlparse, urlunparse, urljoin, splituser, quote,
72+
from urllib.parse import (urlparse, urlunparse, urljoin, quote,
7273
unquote, urlsplit, urlunsplit, splittype)
7374
from urllib.request import (urlopen, urlretrieve, Request, url2pathname,
7475
pathname2url,
@@ -88,6 +89,7 @@ def splituser(host):
8889
from itertools import filterfalse
8990
filter = filter
9091

92+
9193
try:
9294
from ssl import match_hostname, CertificateError
9395
except ImportError: # pragma: no cover

src/pip/_vendor/distlib/markers.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,29 @@
1313
# as ~= and === which aren't in Python, necessitating a different approach.
1414

1515
import os
16+
import re
1617
import sys
1718
import platform
1819

1920
from .compat import string_types
2021
from .util import in_venv, parse_marker
22+
from .version import NormalizedVersion as NV
2123

2224
__all__ = ['interpret']
2325

26+
_VERSION_PATTERN = re.compile(r'((\d+(\.\d+)*\w*)|\'(\d+(\.\d+)*\w*)\'|\"(\d+(\.\d+)*\w*)\")')
27+
2428
def _is_literal(o):
2529
if not isinstance(o, string_types) or not o:
2630
return False
2731
return o[0] in '\'"'
2832

33+
def _get_versions(s):
34+
result = []
35+
for m in _VERSION_PATTERN.finditer(s):
36+
result.append(NV(m.groups()[0]))
37+
return set(result)
38+
2939
class Evaluator(object):
3040
"""
3141
This class is used to evaluate marker expessions.
@@ -70,6 +80,13 @@ def evaluate(self, expr, context):
7080

7181
lhs = self.evaluate(elhs, context)
7282
rhs = self.evaluate(erhs, context)
83+
if ((elhs == 'python_version' or erhs == 'python_version') and
84+
op in ('<', '<=', '>', '>=', '===', '==', '!=', '~=')):
85+
lhs = NV(lhs)
86+
rhs = NV(rhs)
87+
elif elhs == 'python_version' and op in ('in', 'not in'):
88+
lhs = NV(lhs)
89+
rhs = _get_versions(rhs)
7390
result = self.operations[op](lhs, rhs)
7491
return result
7592

src/pip/_vendor/distlib/scripts.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from .compat import sysconfig, detect_encoding, ZipFile
1515
from .resources import finder
1616
from .util import (FileOperator, get_export_entry, convert_path,
17-
get_executable, in_venv)
17+
get_executable, get_platform, in_venv)
1818

1919
logger = logging.getLogger(__name__)
2020

@@ -170,6 +170,11 @@ def _get_shebang(self, encoding, post_interp=b'', options=None):
170170
sysconfig.get_config_var('BINDIR'),
171171
'python%s%s' % (sysconfig.get_config_var('VERSION'),
172172
sysconfig.get_config_var('EXE')))
173+
if not os.path.isfile(executable):
174+
# for Python builds from source on Windows, no Python executables with
175+
# a version suffix are created, so we use python.exe
176+
executable = os.path.join(sysconfig.get_config_var('BINDIR'),
177+
'python%s' % (sysconfig.get_config_var('EXE')))
173178
if options:
174179
executable = self._get_alternate_executable(executable, options)
175180

@@ -379,7 +384,8 @@ def _get_launcher(self, kind):
379384
bits = '64'
380385
else:
381386
bits = '32'
382-
name = '%s%s.exe' % (kind, bits)
387+
platform_suffix = '-arm' if get_platform() == 'win-arm64' else ''
388+
name = '%s%s%s.exe' % (kind, bits, platform_suffix)
383389
# Issue 31: don't hardcode an absolute package name, but
384390
# determine it relative to the current package
385391
distlib_package = __name__.rsplit('.', 1)[0]

src/pip/_vendor/distlib/t64-arm.exe

177 KB
Binary file not shown.

src/pip/_vendor/distlib/util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ def get_versions(ver_remaining):
215215
if not ver_remaining or ver_remaining[0] != ',':
216216
break
217217
ver_remaining = ver_remaining[1:].lstrip()
218+
# Some packages have a trailing comma which would break things
219+
# See issue #148
220+
if not ver_remaining:
221+
break
218222
m = COMPARE_OP.match(ver_remaining)
219223
if not m:
220224
raise SyntaxError('invalid constraint: %s' % ver_remaining)

src/pip/_vendor/distlib/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def _pep_440_key(s):
194194
if not groups[0]:
195195
epoch = 0
196196
else:
197-
epoch = int(groups[0])
197+
epoch = int(groups[0][:-1])
198198
pre = groups[4:6]
199199
post = groups[7:9]
200200
dev = groups[10:12]

src/pip/_vendor/distlib/w64-arm.exe

163 KB
Binary file not shown.

0 commit comments

Comments
 (0)