Skip to content

Commit c7ace4d

Browse files
committed
Upgrade packaging to 20.9
1 parent d1aa391 commit c7ace4d

File tree

8 files changed

+123
-20
lines changed

8 files changed

+123
-20
lines changed

news/packaging.vendor.rst

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

src/pip/_vendor/packaging/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
__summary__ = "Core utilities for Python packages"
1919
__uri__ = "https://github.com/pypa/packaging"
2020

21-
__version__ = "20.8"
21+
__version__ = "20.9"
2222

2323
__author__ = "Donald Stufft and individual contributors"
2424
__email__ = "[email protected]"

src/pip/_vendor/packaging/markers.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@
88
import platform
99
import sys
1010

11-
from pip._vendor.pyparsing import ParseException, ParseResults, stringStart, stringEnd
12-
from pip._vendor.pyparsing import ZeroOrMore, Group, Forward, QuotedString
13-
from pip._vendor.pyparsing import Literal as L # noqa
11+
from pip._vendor.pyparsing import ( # noqa: N817
12+
Forward,
13+
Group,
14+
Literal as L,
15+
ParseException,
16+
ParseResults,
17+
QuotedString,
18+
ZeroOrMore,
19+
stringEnd,
20+
stringStart,
21+
)
1422

1523
from ._compat import string_types
1624
from ._typing import TYPE_CHECKING
17-
from .specifiers import Specifier, InvalidSpecifier
25+
from .specifiers import InvalidSpecifier, Specifier
1826

1927
if TYPE_CHECKING: # pragma: no cover
2028
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

src/pip/_vendor/packaging/requirements.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,22 @@
33
# for complete details.
44
from __future__ import absolute_import, division, print_function
55

6-
import string
76
import re
7+
import string
88
import sys
99

10-
from pip._vendor.pyparsing import stringStart, stringEnd, originalTextFor, ParseException
11-
from pip._vendor.pyparsing import ZeroOrMore, Word, Optional, Regex, Combine
12-
from pip._vendor.pyparsing import Literal as L # noqa
10+
from pip._vendor.pyparsing import ( # noqa: N817
11+
Combine,
12+
Literal as L,
13+
Optional,
14+
ParseException,
15+
Regex,
16+
Word,
17+
ZeroOrMore,
18+
originalTextFor,
19+
stringEnd,
20+
stringStart,
21+
)
1322

1423
from ._typing import TYPE_CHECKING
1524
from .markers import MARKER_EXPR, Marker

src/pip/_vendor/packaging/specifiers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
from ._compat import string_types, with_metaclass
1313
from ._typing import TYPE_CHECKING
1414
from .utils import canonicalize_version
15-
from .version import Version, LegacyVersion, parse
15+
from .version import LegacyVersion, Version, parse
1616

1717
if TYPE_CHECKING: # pragma: no cover
18-
from typing import List, Dict, Union, Iterable, Iterator, Optional, Callable, Tuple
18+
from typing import Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union
1919

2020
ParsedVersion = Union[Version, LegacyVersion]
2121
UnparsedVersion = Union[Version, LegacyVersion, str]

src/pip/_vendor/packaging/tags.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727

2828
if TYPE_CHECKING: # pragma: no cover
2929
from typing import (
30+
IO,
3031
Dict,
3132
FrozenSet,
32-
IO,
3333
Iterable,
3434
Iterator,
3535
List,
@@ -458,14 +458,28 @@ def mac_platforms(version=None, arch=None):
458458
major=major_version, minor=0, binary_format=binary_format
459459
)
460460

461-
if version >= (11, 0) and arch == "x86_64":
461+
if version >= (11, 0):
462462
# Mac OS 11 on x86_64 is compatible with binaries from previous releases.
463463
# Arm64 support was introduced in 11.0, so no Arm binaries from previous
464464
# releases exist.
465-
for minor_version in range(16, 3, -1):
466-
compat_version = 10, minor_version
467-
binary_formats = _mac_binary_formats(compat_version, arch)
468-
for binary_format in binary_formats:
465+
#
466+
# However, the "universal2" binary format can have a
467+
# macOS version earlier than 11.0 when the x86_64 part of the binary supports
468+
# that version of macOS.
469+
if arch == "x86_64":
470+
for minor_version in range(16, 3, -1):
471+
compat_version = 10, minor_version
472+
binary_formats = _mac_binary_formats(compat_version, arch)
473+
for binary_format in binary_formats:
474+
yield "macosx_{major}_{minor}_{binary_format}".format(
475+
major=compat_version[0],
476+
minor=compat_version[1],
477+
binary_format=binary_format,
478+
)
479+
else:
480+
for minor_version in range(16, 3, -1):
481+
compat_version = 10, minor_version
482+
binary_format = "universal2"
469483
yield "macosx_{major}_{minor}_{binary_format}".format(
470484
major=compat_version[0],
471485
minor=compat_version[1],

src/pip/_vendor/packaging/utils.py

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,41 @@
66
import re
77

88
from ._typing import TYPE_CHECKING, cast
9+
from .tags import Tag, parse_tag
910
from .version import InvalidVersion, Version
1011

1112
if TYPE_CHECKING: # pragma: no cover
12-
from typing import NewType, Union
13+
from typing import FrozenSet, NewType, Tuple, Union
1314

15+
BuildTag = Union[Tuple[()], Tuple[int, str]]
1416
NormalizedName = NewType("NormalizedName", str)
1517
else:
18+
BuildTag = tuple
1619
NormalizedName = str
1720

21+
22+
class InvalidWheelFilename(ValueError):
23+
"""
24+
An invalid wheel filename was found, users should refer to PEP 427.
25+
"""
26+
27+
28+
class InvalidSdistFilename(ValueError):
29+
"""
30+
An invalid sdist filename was found, users should refer to the packaging user guide.
31+
"""
32+
33+
1834
_canonicalize_regex = re.compile(r"[-_.]+")
35+
# PEP 427: The build number must start with a digit.
36+
_build_tag_regex = re.compile(r"(\d+)(.*)")
1937

2038

2139
def canonicalize_name(name):
2240
# type: (str) -> NormalizedName
2341
# This is taken from PEP 503.
2442
value = _canonicalize_regex.sub("-", name).lower()
25-
return cast("NormalizedName", value)
43+
return cast(NormalizedName, value)
2644

2745

2846
def canonicalize_version(version):
@@ -65,3 +83,56 @@ def canonicalize_version(version):
6583
parts.append("+{0}".format(version.local))
6684

6785
return "".join(parts)
86+
87+
88+
def parse_wheel_filename(filename):
89+
# type: (str) -> Tuple[NormalizedName, Version, BuildTag, FrozenSet[Tag]]
90+
if not filename.endswith(".whl"):
91+
raise InvalidWheelFilename(
92+
"Invalid wheel filename (extension must be '.whl'): {0}".format(filename)
93+
)
94+
95+
filename = filename[:-4]
96+
dashes = filename.count("-")
97+
if dashes not in (4, 5):
98+
raise InvalidWheelFilename(
99+
"Invalid wheel filename (wrong number of parts): {0}".format(filename)
100+
)
101+
102+
parts = filename.split("-", dashes - 2)
103+
name_part = parts[0]
104+
# See PEP 427 for the rules on escaping the project name
105+
if "__" in name_part or re.match(r"^[\w\d._]*$", name_part, re.UNICODE) is None:
106+
raise InvalidWheelFilename("Invalid project name: {0}".format(filename))
107+
name = canonicalize_name(name_part)
108+
version = Version(parts[1])
109+
if dashes == 5:
110+
build_part = parts[2]
111+
build_match = _build_tag_regex.match(build_part)
112+
if build_match is None:
113+
raise InvalidWheelFilename(
114+
"Invalid build number: {0} in '{1}'".format(build_part, filename)
115+
)
116+
build = cast(BuildTag, (int(build_match.group(1)), build_match.group(2)))
117+
else:
118+
build = ()
119+
tags = parse_tag(parts[-1])
120+
return (name, version, build, tags)
121+
122+
123+
def parse_sdist_filename(filename):
124+
# type: (str) -> Tuple[NormalizedName, Version]
125+
if not filename.endswith(".tar.gz"):
126+
raise InvalidSdistFilename(
127+
"Invalid sdist filename (extension must be '.tar.gz'): {0}".format(filename)
128+
)
129+
130+
# We are requiring a PEP 440 version, which cannot contain dashes,
131+
# so we split on the last dash.
132+
name_part, sep, version_part = filename[:-7].rpartition("-")
133+
if not sep:
134+
raise InvalidSdistFilename("Invalid sdist filename: {0}".format(filename))
135+
136+
name = canonicalize_name(name_part)
137+
version = Version(version_part)
138+
return (name, version)

src/pip/_vendor/vendor.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ distlib==0.3.1
66
distro==1.5.0
77
html5lib==1.1
88
msgpack==1.0.2
9-
packaging==20.8
9+
packaging==20.9
1010
pep517==0.9.1
1111
progress==1.5
1212
pyparsing==2.4.7

0 commit comments

Comments
 (0)