mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Merge pull request #9533 from henryiii/chore/packaging-20.9
Update to packaging 20.9
This commit is contained in:
commit
00fb5a0b22
8 changed files with 123 additions and 20 deletions
1
news/packaging.vendor.rst
Normal file
1
news/packaging.vendor.rst
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Upgrade packaging to 20.9
|
|
@ -18,7 +18,7 @@ __title__ = "packaging"
|
||||||
__summary__ = "Core utilities for Python packages"
|
__summary__ = "Core utilities for Python packages"
|
||||||
__uri__ = "https://github.com/pypa/packaging"
|
__uri__ = "https://github.com/pypa/packaging"
|
||||||
|
|
||||||
__version__ = "20.8"
|
__version__ = "20.9"
|
||||||
|
|
||||||
__author__ = "Donald Stufft and individual contributors"
|
__author__ = "Donald Stufft and individual contributors"
|
||||||
__email__ = "donald@stufft.io"
|
__email__ = "donald@stufft.io"
|
||||||
|
|
|
@ -8,13 +8,21 @@ import os
|
||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from pip._vendor.pyparsing import ParseException, ParseResults, stringStart, stringEnd
|
from pip._vendor.pyparsing import ( # noqa: N817
|
||||||
from pip._vendor.pyparsing import ZeroOrMore, Group, Forward, QuotedString
|
Forward,
|
||||||
from pip._vendor.pyparsing import Literal as L # noqa
|
Group,
|
||||||
|
Literal as L,
|
||||||
|
ParseException,
|
||||||
|
ParseResults,
|
||||||
|
QuotedString,
|
||||||
|
ZeroOrMore,
|
||||||
|
stringEnd,
|
||||||
|
stringStart,
|
||||||
|
)
|
||||||
|
|
||||||
from ._compat import string_types
|
from ._compat import string_types
|
||||||
from ._typing import TYPE_CHECKING
|
from ._typing import TYPE_CHECKING
|
||||||
from .specifiers import Specifier, InvalidSpecifier
|
from .specifiers import InvalidSpecifier, Specifier
|
||||||
|
|
||||||
if TYPE_CHECKING: # pragma: no cover
|
if TYPE_CHECKING: # pragma: no cover
|
||||||
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
||||||
|
|
|
@ -3,13 +3,22 @@
|
||||||
# for complete details.
|
# for complete details.
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
import string
|
|
||||||
import re
|
import re
|
||||||
|
import string
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from pip._vendor.pyparsing import stringStart, stringEnd, originalTextFor, ParseException
|
from pip._vendor.pyparsing import ( # noqa: N817
|
||||||
from pip._vendor.pyparsing import ZeroOrMore, Word, Optional, Regex, Combine
|
Combine,
|
||||||
from pip._vendor.pyparsing import Literal as L # noqa
|
Literal as L,
|
||||||
|
Optional,
|
||||||
|
ParseException,
|
||||||
|
Regex,
|
||||||
|
Word,
|
||||||
|
ZeroOrMore,
|
||||||
|
originalTextFor,
|
||||||
|
stringEnd,
|
||||||
|
stringStart,
|
||||||
|
)
|
||||||
|
|
||||||
from ._typing import TYPE_CHECKING
|
from ._typing import TYPE_CHECKING
|
||||||
from .markers import MARKER_EXPR, Marker
|
from .markers import MARKER_EXPR, Marker
|
||||||
|
|
|
@ -12,10 +12,10 @@ import warnings
|
||||||
from ._compat import string_types, with_metaclass
|
from ._compat import string_types, with_metaclass
|
||||||
from ._typing import TYPE_CHECKING
|
from ._typing import TYPE_CHECKING
|
||||||
from .utils import canonicalize_version
|
from .utils import canonicalize_version
|
||||||
from .version import Version, LegacyVersion, parse
|
from .version import LegacyVersion, Version, parse
|
||||||
|
|
||||||
if TYPE_CHECKING: # pragma: no cover
|
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]
|
ParsedVersion = Union[Version, LegacyVersion]
|
||||||
UnparsedVersion = Union[Version, LegacyVersion, str]
|
UnparsedVersion = Union[Version, LegacyVersion, str]
|
||||||
|
|
|
@ -27,9 +27,9 @@ from ._typing import TYPE_CHECKING, cast
|
||||||
|
|
||||||
if TYPE_CHECKING: # pragma: no cover
|
if TYPE_CHECKING: # pragma: no cover
|
||||||
from typing import (
|
from typing import (
|
||||||
|
IO,
|
||||||
Dict,
|
Dict,
|
||||||
FrozenSet,
|
FrozenSet,
|
||||||
IO,
|
|
||||||
Iterable,
|
Iterable,
|
||||||
Iterator,
|
Iterator,
|
||||||
List,
|
List,
|
||||||
|
@ -458,10 +458,15 @@ def mac_platforms(version=None, arch=None):
|
||||||
major=major_version, minor=0, binary_format=binary_format
|
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.
|
# 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
|
# Arm64 support was introduced in 11.0, so no Arm binaries from previous
|
||||||
# releases exist.
|
# releases exist.
|
||||||
|
#
|
||||||
|
# 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):
|
for minor_version in range(16, 3, -1):
|
||||||
compat_version = 10, minor_version
|
compat_version = 10, minor_version
|
||||||
binary_formats = _mac_binary_formats(compat_version, arch)
|
binary_formats = _mac_binary_formats(compat_version, arch)
|
||||||
|
@ -471,6 +476,15 @@ def mac_platforms(version=None, arch=None):
|
||||||
minor=compat_version[1],
|
minor=compat_version[1],
|
||||||
binary_format=binary_format,
|
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],
|
||||||
|
binary_format=binary_format,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# From PEP 513, PEP 600
|
# From PEP 513, PEP 600
|
||||||
|
|
|
@ -6,23 +6,41 @@ from __future__ import absolute_import, division, print_function
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from ._typing import TYPE_CHECKING, cast
|
from ._typing import TYPE_CHECKING, cast
|
||||||
|
from .tags import Tag, parse_tag
|
||||||
from .version import InvalidVersion, Version
|
from .version import InvalidVersion, Version
|
||||||
|
|
||||||
if TYPE_CHECKING: # pragma: no cover
|
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)
|
NormalizedName = NewType("NormalizedName", str)
|
||||||
else:
|
else:
|
||||||
|
BuildTag = tuple
|
||||||
NormalizedName = str
|
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"[-_.]+")
|
_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):
|
def canonicalize_name(name):
|
||||||
# type: (str) -> NormalizedName
|
# type: (str) -> NormalizedName
|
||||||
# This is taken from PEP 503.
|
# This is taken from PEP 503.
|
||||||
value = _canonicalize_regex.sub("-", name).lower()
|
value = _canonicalize_regex.sub("-", name).lower()
|
||||||
return cast("NormalizedName", value)
|
return cast(NormalizedName, value)
|
||||||
|
|
||||||
|
|
||||||
def canonicalize_version(version):
|
def canonicalize_version(version):
|
||||||
|
@ -65,3 +83,56 @@ def canonicalize_version(version):
|
||||||
parts.append("+{0}".format(version.local))
|
parts.append("+{0}".format(version.local))
|
||||||
|
|
||||||
return "".join(parts)
|
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)
|
||||||
|
|
|
@ -6,7 +6,7 @@ distlib==0.3.1
|
||||||
distro==1.5.0
|
distro==1.5.0
|
||||||
html5lib==1.1
|
html5lib==1.1
|
||||||
msgpack==1.0.2
|
msgpack==1.0.2
|
||||||
packaging==20.8
|
packaging==20.9
|
||||||
pep517==0.9.1
|
pep517==0.9.1
|
||||||
progress==1.5
|
progress==1.5
|
||||||
pyparsing==2.4.7
|
pyparsing==2.4.7
|
||||||
|
|
Loading…
Reference in a new issue