Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to packaging 20.9 #9533

Merged
merged 1 commit into from Jan 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions news/packaging.vendor.rst
@@ -0,0 +1 @@
Upgrade packaging to 20.9
2 changes: 1 addition & 1 deletion src/pip/_vendor/packaging/__about__.py
Expand Up @@ -18,7 +18,7 @@
__summary__ = "Core utilities for Python packages"
__uri__ = "https://github.com/pypa/packaging"

__version__ = "20.8"
__version__ = "20.9"

__author__ = "Donald Stufft and individual contributors"
__email__ = "donald@stufft.io"
Expand Down
16 changes: 12 additions & 4 deletions src/pip/_vendor/packaging/markers.py
Expand Up @@ -8,13 +8,21 @@
import platform
import sys

from pip._vendor.pyparsing import ParseException, ParseResults, stringStart, stringEnd
from pip._vendor.pyparsing import ZeroOrMore, Group, Forward, QuotedString
from pip._vendor.pyparsing import Literal as L # noqa
from pip._vendor.pyparsing import ( # noqa: N817
Forward,
Group,
Literal as L,
ParseException,
ParseResults,
QuotedString,
ZeroOrMore,
stringEnd,
stringStart,
)

from ._compat import string_types
from ._typing import TYPE_CHECKING
from .specifiers import Specifier, InvalidSpecifier
from .specifiers import InvalidSpecifier, Specifier

if TYPE_CHECKING: # pragma: no cover
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
Expand Down
17 changes: 13 additions & 4 deletions src/pip/_vendor/packaging/requirements.py
Expand Up @@ -3,13 +3,22 @@
# for complete details.
from __future__ import absolute_import, division, print_function

import string
import re
import string
import sys

from pip._vendor.pyparsing import stringStart, stringEnd, originalTextFor, ParseException
from pip._vendor.pyparsing import ZeroOrMore, Word, Optional, Regex, Combine
from pip._vendor.pyparsing import Literal as L # noqa
from pip._vendor.pyparsing import ( # noqa: N817
Combine,
Literal as L,
Optional,
ParseException,
Regex,
Word,
ZeroOrMore,
originalTextFor,
stringEnd,
stringStart,
)

from ._typing import TYPE_CHECKING
from .markers import MARKER_EXPR, Marker
Expand Down
4 changes: 2 additions & 2 deletions src/pip/_vendor/packaging/specifiers.py
Expand Up @@ -12,10 +12,10 @@
from ._compat import string_types, with_metaclass
from ._typing import TYPE_CHECKING
from .utils import canonicalize_version
from .version import Version, LegacyVersion, parse
from .version import LegacyVersion, Version, parse

if TYPE_CHECKING: # pragma: no cover
from typing import List, Dict, Union, Iterable, Iterator, Optional, Callable, Tuple
from typing import Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union

ParsedVersion = Union[Version, LegacyVersion]
UnparsedVersion = Union[Version, LegacyVersion, str]
Expand Down
26 changes: 20 additions & 6 deletions src/pip/_vendor/packaging/tags.py
Expand Up @@ -27,9 +27,9 @@

if TYPE_CHECKING: # pragma: no cover
from typing import (
IO,
Dict,
FrozenSet,
IO,
Iterable,
Iterator,
List,
Expand Down Expand Up @@ -458,14 +458,28 @@ def mac_platforms(version=None, arch=None):
major=major_version, minor=0, binary_format=binary_format
)

if version >= (11, 0) and arch == "x86_64":
if version >= (11, 0):
# Mac OS 11 on x86_64 is compatible with binaries from previous releases.
# Arm64 support was introduced in 11.0, so no Arm binaries from previous
# releases exist.
for minor_version in range(16, 3, -1):
compat_version = 10, minor_version
binary_formats = _mac_binary_formats(compat_version, arch)
for binary_format in binary_formats:
#
# However, the "universal2" binary format can have a
# macOS version earlier than 11.0 when the x86_64 part of the binary supports
# that version of macOS.
if arch == "x86_64":
for minor_version in range(16, 3, -1):
compat_version = 10, minor_version
binary_formats = _mac_binary_formats(compat_version, arch)
for binary_format in binary_formats:
yield "macosx_{major}_{minor}_{binary_format}".format(
major=compat_version[0],
minor=compat_version[1],
binary_format=binary_format,
)
else:
for minor_version in range(16, 3, -1):
compat_version = 10, minor_version
binary_format = "universal2"
yield "macosx_{major}_{minor}_{binary_format}".format(
major=compat_version[0],
minor=compat_version[1],
Expand Down
75 changes: 73 additions & 2 deletions src/pip/_vendor/packaging/utils.py
Expand Up @@ -6,23 +6,41 @@
import re

from ._typing import TYPE_CHECKING, cast
from .tags import Tag, parse_tag
from .version import InvalidVersion, Version

if TYPE_CHECKING: # pragma: no cover
from typing import NewType, Union
from typing import FrozenSet, NewType, Tuple, Union

BuildTag = Union[Tuple[()], Tuple[int, str]]
NormalizedName = NewType("NormalizedName", str)
else:
BuildTag = tuple
NormalizedName = str


class InvalidWheelFilename(ValueError):
"""
An invalid wheel filename was found, users should refer to PEP 427.
"""


class InvalidSdistFilename(ValueError):
"""
An invalid sdist filename was found, users should refer to the packaging user guide.
"""


_canonicalize_regex = re.compile(r"[-_.]+")
# PEP 427: The build number must start with a digit.
_build_tag_regex = re.compile(r"(\d+)(.*)")


def canonicalize_name(name):
# type: (str) -> NormalizedName
# This is taken from PEP 503.
value = _canonicalize_regex.sub("-", name).lower()
return cast("NormalizedName", value)
return cast(NormalizedName, value)


def canonicalize_version(version):
Expand Down Expand Up @@ -65,3 +83,56 @@ def canonicalize_version(version):
parts.append("+{0}".format(version.local))

return "".join(parts)


def parse_wheel_filename(filename):
# type: (str) -> Tuple[NormalizedName, Version, BuildTag, FrozenSet[Tag]]
if not filename.endswith(".whl"):
raise InvalidWheelFilename(
"Invalid wheel filename (extension must be '.whl'): {0}".format(filename)
)

filename = filename[:-4]
dashes = filename.count("-")
if dashes not in (4, 5):
raise InvalidWheelFilename(
"Invalid wheel filename (wrong number of parts): {0}".format(filename)
)

parts = filename.split("-", dashes - 2)
name_part = parts[0]
# See PEP 427 for the rules on escaping the project name
if "__" in name_part or re.match(r"^[\w\d._]*$", name_part, re.UNICODE) is None:
raise InvalidWheelFilename("Invalid project name: {0}".format(filename))
name = canonicalize_name(name_part)
version = Version(parts[1])
if dashes == 5:
build_part = parts[2]
build_match = _build_tag_regex.match(build_part)
if build_match is None:
raise InvalidWheelFilename(
"Invalid build number: {0} in '{1}'".format(build_part, filename)
)
build = cast(BuildTag, (int(build_match.group(1)), build_match.group(2)))
else:
build = ()
tags = parse_tag(parts[-1])
return (name, version, build, tags)


def parse_sdist_filename(filename):
# type: (str) -> Tuple[NormalizedName, Version]
if not filename.endswith(".tar.gz"):
raise InvalidSdistFilename(
"Invalid sdist filename (extension must be '.tar.gz'): {0}".format(filename)
)

# We are requiring a PEP 440 version, which cannot contain dashes,
# so we split on the last dash.
name_part, sep, version_part = filename[:-7].rpartition("-")
if not sep:
raise InvalidSdistFilename("Invalid sdist filename: {0}".format(filename))

name = canonicalize_name(name_part)
version = Version(version_part)
return (name, version)
2 changes: 1 addition & 1 deletion src/pip/_vendor/vendor.txt
Expand Up @@ -6,7 +6,7 @@ distlib==0.3.1
distro==1.5.0
html5lib==1.1
msgpack==1.0.2
packaging==20.8
packaging==20.9
pep517==0.9.1
progress==1.5
pyparsing==2.4.7
Expand Down