Skip to content

Commit 169eebd

Browse files
authored
Merge pull request #6151 from pradyunsg/vendoring/packaging-19
Update packaging to 19.0
2 parents 6a62aaf + c90a3ff commit 169eebd

File tree

11 files changed

+131
-162
lines changed

11 files changed

+131
-162
lines changed

news/packaging.vendor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update packaging to 19.0

src/pip/_vendor/packaging/__about__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,24 @@
44
from __future__ import absolute_import, division, print_function
55

66
__all__ = [
7-
"__title__", "__summary__", "__uri__", "__version__", "__author__",
8-
"__email__", "__license__", "__copyright__",
7+
"__title__",
8+
"__summary__",
9+
"__uri__",
10+
"__version__",
11+
"__author__",
12+
"__email__",
13+
"__license__",
14+
"__copyright__",
915
]
1016

1117
__title__ = "packaging"
1218
__summary__ = "Core utilities for Python packages"
1319
__uri__ = "https://github.com/pypa/packaging"
1420

15-
__version__ = "18.0"
21+
__version__ = "19.0"
1622

1723
__author__ = "Donald Stufft and individual contributors"
1824
__email__ = "[email protected]"
1925

2026
__license__ = "BSD or Apache License, Version 2.0"
21-
__copyright__ = "Copyright 2014-2018 %s" % __author__
27+
__copyright__ = "Copyright 2014-2019 %s" % __author__

src/pip/_vendor/packaging/__init__.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,23 @@
44
from __future__ import absolute_import, division, print_function
55

66
from .__about__ import (
7-
__author__, __copyright__, __email__, __license__, __summary__, __title__,
8-
__uri__, __version__
7+
__author__,
8+
__copyright__,
9+
__email__,
10+
__license__,
11+
__summary__,
12+
__title__,
13+
__uri__,
14+
__version__,
915
)
1016

1117
__all__ = [
12-
"__title__", "__summary__", "__uri__", "__version__", "__author__",
13-
"__email__", "__license__", "__copyright__",
18+
"__title__",
19+
"__summary__",
20+
"__uri__",
21+
"__version__",
22+
"__author__",
23+
"__email__",
24+
"__license__",
25+
"__copyright__",
1426
]

src/pip/_vendor/packaging/_compat.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# flake8: noqa
1313

1414
if PY3:
15-
string_types = str,
15+
string_types = (str,)
1616
else:
17-
string_types = basestring,
17+
string_types = (basestring,)
1818

1919

2020
def with_metaclass(meta, *bases):
@@ -27,4 +27,5 @@ def with_metaclass(meta, *bases):
2727
class metaclass(meta):
2828
def __new__(cls, name, this_bases, d):
2929
return meta(name, bases, d)
30-
return type.__new__(metaclass, 'temporary_class', (), {})
30+
31+
return type.__new__(metaclass, "temporary_class", (), {})

src/pip/_vendor/packaging/_structures.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66

77
class Infinity(object):
8-
98
def __repr__(self):
109
return "Infinity"
1110

@@ -38,7 +37,6 @@ def __neg__(self):
3837

3938

4039
class NegativeInfinity(object):
41-
4240
def __repr__(self):
4341
return "-Infinity"
4442

src/pip/_vendor/packaging/markers.py

Lines changed: 42 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717

1818

1919
__all__ = [
20-
"InvalidMarker", "UndefinedComparison", "UndefinedEnvironmentName",
21-
"Marker", "default_environment",
20+
"InvalidMarker",
21+
"UndefinedComparison",
22+
"UndefinedEnvironmentName",
23+
"Marker",
24+
"default_environment",
2225
]
2326

2427

@@ -42,7 +45,6 @@ class UndefinedEnvironmentName(ValueError):
4245

4346

4447
class Node(object):
45-
4648
def __init__(self, value):
4749
self.value = value
4850

@@ -57,62 +59,52 @@ def serialize(self):
5759

5860

5961
class Variable(Node):
60-
6162
def serialize(self):
6263
return str(self)
6364

6465

6566
class Value(Node):
66-
6767
def serialize(self):
6868
return '"{0}"'.format(self)
6969

7070

7171
class Op(Node):
72-
7372
def serialize(self):
7473
return str(self)
7574

7675

7776
VARIABLE = (
78-
L("implementation_version") |
79-
L("platform_python_implementation") |
80-
L("implementation_name") |
81-
L("python_full_version") |
82-
L("platform_release") |
83-
L("platform_version") |
84-
L("platform_machine") |
85-
L("platform_system") |
86-
L("python_version") |
87-
L("sys_platform") |
88-
L("os_name") |
89-
L("os.name") | # PEP-345
90-
L("sys.platform") | # PEP-345
91-
L("platform.version") | # PEP-345
92-
L("platform.machine") | # PEP-345
93-
L("platform.python_implementation") | # PEP-345
94-
L("python_implementation") | # undocumented setuptools legacy
95-
L("extra")
77+
L("implementation_version")
78+
| L("platform_python_implementation")
79+
| L("implementation_name")
80+
| L("python_full_version")
81+
| L("platform_release")
82+
| L("platform_version")
83+
| L("platform_machine")
84+
| L("platform_system")
85+
| L("python_version")
86+
| L("sys_platform")
87+
| L("os_name")
88+
| L("os.name")
89+
| L("sys.platform") # PEP-345
90+
| L("platform.version") # PEP-345
91+
| L("platform.machine") # PEP-345
92+
| L("platform.python_implementation") # PEP-345
93+
| L("python_implementation") # PEP-345
94+
| L("extra") # undocumented setuptools legacy
9695
)
9796
ALIASES = {
98-
'os.name': 'os_name',
99-
'sys.platform': 'sys_platform',
100-
'platform.version': 'platform_version',
101-
'platform.machine': 'platform_machine',
102-
'platform.python_implementation': 'platform_python_implementation',
103-
'python_implementation': 'platform_python_implementation'
97+
"os.name": "os_name",
98+
"sys.platform": "sys_platform",
99+
"platform.version": "platform_version",
100+
"platform.machine": "platform_machine",
101+
"platform.python_implementation": "platform_python_implementation",
102+
"python_implementation": "platform_python_implementation",
104103
}
105104
VARIABLE.setParseAction(lambda s, l, t: Variable(ALIASES.get(t[0], t[0])))
106105

107106
VERSION_CMP = (
108-
L("===") |
109-
L("==") |
110-
L(">=") |
111-
L("<=") |
112-
L("!=") |
113-
L("~=") |
114-
L(">") |
115-
L("<")
107+
L("===") | L("==") | L(">=") | L("<=") | L("!=") | L("~=") | L(">") | L("<")
116108
)
117109

118110
MARKER_OP = VERSION_CMP | L("not in") | L("in")
@@ -152,8 +144,11 @@ def _format_marker(marker, first=True):
152144
# where the single item is itself it's own list. In that case we want skip
153145
# the rest of this function so that we don't get extraneous () on the
154146
# outside.
155-
if (isinstance(marker, list) and len(marker) == 1 and
156-
isinstance(marker[0], (list, tuple))):
147+
if (
148+
isinstance(marker, list)
149+
and len(marker) == 1
150+
and isinstance(marker[0], (list, tuple))
151+
):
157152
return _format_marker(marker[0])
158153

159154
if isinstance(marker, list):
@@ -239,20 +234,20 @@ def _evaluate_markers(markers, environment):
239234

240235

241236
def format_full_version(info):
242-
version = '{0.major}.{0.minor}.{0.micro}'.format(info)
237+
version = "{0.major}.{0.minor}.{0.micro}".format(info)
243238
kind = info.releaselevel
244-
if kind != 'final':
239+
if kind != "final":
245240
version += kind[0] + str(info.serial)
246241
return version
247242

248243

249244
def default_environment():
250-
if hasattr(sys, 'implementation'):
245+
if hasattr(sys, "implementation"):
251246
iver = format_full_version(sys.implementation.version)
252247
implementation_name = sys.implementation.name
253248
else:
254-
iver = '0'
255-
implementation_name = ''
249+
iver = "0"
250+
implementation_name = ""
256251

257252
return {
258253
"implementation_name": implementation_name,
@@ -270,13 +265,13 @@ def default_environment():
270265

271266

272267
class Marker(object):
273-
274268
def __init__(self, marker):
275269
try:
276270
self._markers = _coerce_parse_result(MARKER.parseString(marker))
277271
except ParseException as e:
278272
err_str = "Invalid marker: {0!r}, parse error at {1!r}".format(
279-
marker, marker[e.loc:e.loc + 8])
273+
marker, marker[e.loc : e.loc + 8]
274+
)
280275
raise InvalidMarker(err_str)
281276

282277
def __str__(self):

src/pip/_vendor/packaging/requirements.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class InvalidRequirement(ValueError):
3838
NAME = IDENTIFIER("name")
3939
EXTRA = IDENTIFIER
4040

41-
URI = Regex(r'[^ ]+')("url")
42-
URL = (AT + URI)
41+
URI = Regex(r"[^ ]+")("url")
42+
URL = AT + URI
4343

4444
EXTRAS_LIST = EXTRA + ZeroOrMore(COMMA + EXTRA)
4545
EXTRAS = (LBRACKET + Optional(EXTRAS_LIST) + RBRACKET)("extras")
@@ -48,26 +48,26 @@ class InvalidRequirement(ValueError):
4848
VERSION_LEGACY = Regex(LegacySpecifier._regex_str, re.VERBOSE | re.IGNORECASE)
4949

5050
VERSION_ONE = VERSION_PEP440 ^ VERSION_LEGACY
51-
VERSION_MANY = Combine(VERSION_ONE + ZeroOrMore(COMMA + VERSION_ONE),
52-
joinString=",", adjacent=False)("_raw_spec")
51+
VERSION_MANY = Combine(
52+
VERSION_ONE + ZeroOrMore(COMMA + VERSION_ONE), joinString=",", adjacent=False
53+
)("_raw_spec")
5354
_VERSION_SPEC = Optional(((LPAREN + VERSION_MANY + RPAREN) | VERSION_MANY))
54-
_VERSION_SPEC.setParseAction(lambda s, l, t: t._raw_spec or '')
55+
_VERSION_SPEC.setParseAction(lambda s, l, t: t._raw_spec or "")
5556

5657
VERSION_SPEC = originalTextFor(_VERSION_SPEC)("specifier")
5758
VERSION_SPEC.setParseAction(lambda s, l, t: t[1])
5859

5960
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
6061
MARKER_EXPR.setParseAction(
61-
lambda s, l, t: Marker(s[t._original_start:t._original_end])
62+
lambda s, l, t: Marker(s[t._original_start : t._original_end])
6263
)
6364
MARKER_SEPARATOR = SEMICOLON
6465
MARKER = MARKER_SEPARATOR + MARKER_EXPR
6566

6667
VERSION_AND_MARKER = VERSION_SPEC + Optional(MARKER)
6768
URL_AND_MARKER = URL + Optional(MARKER)
6869

69-
NAMED_REQUIREMENT = \
70-
NAME + Optional(EXTRAS) + (URL_AND_MARKER | VERSION_AND_MARKER)
70+
NAMED_REQUIREMENT = NAME + Optional(EXTRAS) + (URL_AND_MARKER | VERSION_AND_MARKER)
7171

7272
REQUIREMENT = stringStart + NAMED_REQUIREMENT + stringEnd
7373
# pyparsing isn't thread safe during initialization, so we do it eagerly, see
@@ -92,15 +92,21 @@ def __init__(self, requirement_string):
9292
try:
9393
req = REQUIREMENT.parseString(requirement_string)
9494
except ParseException as e:
95-
raise InvalidRequirement("Parse error at \"{0!r}\": {1}".format(
96-
requirement_string[e.loc:e.loc + 8], e.msg
97-
))
95+
raise InvalidRequirement(
96+
'Parse error at "{0!r}": {1}'.format(
97+
requirement_string[e.loc : e.loc + 8], e.msg
98+
)
99+
)
98100

99101
self.name = req.name
100102
if req.url:
101103
parsed_url = urlparse.urlparse(req.url)
102-
if not (parsed_url.scheme and parsed_url.netloc) or (
103-
not parsed_url.scheme and not parsed_url.netloc):
104+
if parsed_url.scheme == "file":
105+
if urlparse.urlunparse(parsed_url) != req.url:
106+
raise InvalidRequirement("Invalid URL given")
107+
elif not (parsed_url.scheme and parsed_url.netloc) or (
108+
not parsed_url.scheme and not parsed_url.netloc
109+
):
104110
raise InvalidRequirement("Invalid URL: {0}".format(req.url))
105111
self.url = req.url
106112
else:
@@ -120,6 +126,8 @@ def __str__(self):
120126

121127
if self.url:
122128
parts.append("@ {0}".format(self.url))
129+
if self.marker:
130+
parts.append(" ")
123131

124132
if self.marker:
125133
parts.append("; {0}".format(self.marker))

0 commit comments

Comments
 (0)