Skip to content

Commit 1a9a706

Browse files
authored
Update vendored packaging version to 24.2 (#4740)
2 parents b73e99c + 061d93f commit 1a9a706

File tree

24 files changed

+1203
-172
lines changed

24 files changed

+1203
-172
lines changed

newsfragments/4740.feature.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Updated vendored packaging version to 24.2.

pyproject.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ test = [
4141
"virtualenv>=13.0.0",
4242
"wheel>=0.44.0", # Consistent requirement normalisation in METADATA (see #4547)
4343
"pip>=19.1", # For proper file:// URLs support.
44-
"packaging>=23.2",
44+
"packaging>=24.2",
4545
"jaraco.envs>=2.2",
4646
"pytest-xdist>=3", # Dropped dependency on pytest-fork and py
4747
"jaraco.path>=3.2.0",
@@ -90,7 +90,7 @@ doc = [
9090
ssl = []
9191
certs = []
9292
core = [
93-
"packaging>=24",
93+
"packaging>=24.2",
9494
"more_itertools>=8.8",
9595
"jaraco.text>=3.7",
9696
"importlib_metadata>=6; python_version < '3.10'",
@@ -134,7 +134,7 @@ type = [
134134

135135
# pin mypy version so a new version doesn't suddenly cause the CI to fail,
136136
# until types-setuptools is removed from typeshed.
137-
# For help with static-typing issues, or mypy update, ping @Avasam
137+
# For help with static-typing issues, or mypy update, ping @Avasam
138138
"mypy==1.12.*",
139139
# Typing fixes in version newer than we require at runtime
140140
"importlib_metadata>=7.0.2; python_version < '3.10'",

setuptools/_vendor/packaging-24.1.dist-info/INSTALLER

-1
This file was deleted.

setuptools/_vendor/packaging-24.1.dist-info/RECORD

-37
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uv

setuptools/_vendor/packaging-24.1.dist-info/METADATA renamed to setuptools/_vendor/packaging-24.2.dist-info/METADATA

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Metadata-Version: 2.1
1+
Metadata-Version: 2.3
22
Name: packaging
3-
Version: 24.1
3+
Version: 24.2
44
Summary: Core utilities for Python packages
55
Author-email: Donald Stufft <[email protected]>
66
Requires-Python: >=3.8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
packaging-24.2.dist-info/INSTALLER,sha256=5hhM4Q4mYTT9z6QB6PGpUAW81PGNFrYrdXMj4oM_6ak,2
2+
packaging-24.2.dist-info/LICENSE,sha256=ytHvW9NA1z4HS6YU0m996spceUDD2MNIUuZcSQlobEg,197
3+
packaging-24.2.dist-info/LICENSE.APACHE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
4+
packaging-24.2.dist-info/LICENSE.BSD,sha256=tw5-m3QvHMb5SLNMFqo5_-zpQZY2S8iP8NIYDwAo-sU,1344
5+
packaging-24.2.dist-info/METADATA,sha256=ohH86s6k5mIfQxY2TS0LcSfADeOFa4BiCC-bxZV-pNs,3204
6+
packaging-24.2.dist-info/RECORD,,
7+
packaging-24.2.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8+
packaging-24.2.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
9+
packaging/__init__.py,sha256=dk4Ta_vmdVJxYHDcfyhvQNw8V3PgSBomKNXqg-D2JDY,494
10+
packaging/_elffile.py,sha256=cflAQAkE25tzhYmq_aCi72QfbT_tn891tPzfpbeHOwE,3306
11+
packaging/_manylinux.py,sha256=vl5OCoz4kx80H5rwXKeXWjl9WNISGmr4ZgTpTP9lU9c,9612
12+
packaging/_musllinux.py,sha256=p9ZqNYiOItGee8KcZFeHF_YcdhVwGHdK6r-8lgixvGQ,2694
13+
packaging/_parser.py,sha256=s_TvTvDNK0NrM2QB3VKThdWFM4Nc0P6JnkObkl3MjpM,10236
14+
packaging/_structures.py,sha256=q3eVNmbWJGG_S0Dit_S3Ao8qQqz_5PYTXFAKBZe5yr4,1431
15+
packaging/_tokenizer.py,sha256=J6v5H7Jzvb-g81xp_2QACKwO7LxHQA6ikryMU7zXwN8,5273
16+
packaging/licenses/__init__.py,sha256=1x5M1nEYjcgwEbLt0dXwz2ukjr18DiCzC0sraQqJ-Ww,5715
17+
packaging/licenses/_spdx.py,sha256=oAm1ztPFwlsmCKe7lAAsv_OIOfS1cWDu9bNBkeu-2ns,48398
18+
packaging/markers.py,sha256=c89TNzB7ZdGYhkovm6PYmqGyHxXlYVaLW591PHUNKD8,10561
19+
packaging/metadata.py,sha256=YJibM7GYe4re8-0a3OlXmGS-XDgTEoO4tlBt2q25Bng,34762
20+
packaging/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21+
packaging/requirements.py,sha256=gYyRSAdbrIyKDY66ugIDUQjRMvxkH2ALioTmX3tnL6o,2947
22+
packaging/specifiers.py,sha256=GG1wPNMcL0fMJO68vF53wKMdwnfehDcaI-r9NpTfilA,40074
23+
packaging/tags.py,sha256=CFqrJzAzc2XNGexerH__T-Y5Iwq7WbsYXsiLERLWxY0,21014
24+
packaging/utils.py,sha256=0F3Hh9OFuRgrhTgGZUl5K22Fv1YP2tZl1z_2gO6kJiA,5050
25+
packaging/version.py,sha256=olfyuk_DPbflNkJ4wBWetXQ17c74x3DB501degUv7DY,16676
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Wheel-Version: 1.0
2-
Generator: flit 3.9.0
2+
Generator: flit 3.10.1
33
Root-Is-Purelib: true
44
Tag: py3-none-any

setuptools/_vendor/packaging/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
__summary__ = "Core utilities for Python packages"
77
__uri__ = "https://github.com/pypa/packaging"
88

9-
__version__ = "24.1"
9+
__version__ = "24.2"
1010

1111
__author__ = "Donald Stufft and individual contributors"
1212
__email__ = "[email protected]"
1313

1414
__license__ = "BSD-2-Clause or Apache-2.0"
15-
__copyright__ = "2014 %s" % __author__
15+
__copyright__ = f"2014 {__author__}"

setuptools/_vendor/packaging/_elffile.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def __init__(self, f: IO[bytes]) -> None:
4848

4949
try:
5050
ident = self._read("16B")
51-
except struct.error:
52-
raise ELFInvalid("unable to parse identification")
51+
except struct.error as e:
52+
raise ELFInvalid("unable to parse identification") from e
5353
magic = bytes(ident[:4])
5454
if magic != b"\x7fELF":
5555
raise ELFInvalid(f"invalid magic: {magic!r}")
@@ -67,11 +67,11 @@ def __init__(self, f: IO[bytes]) -> None:
6767
(2, 1): ("<HHIQQQIHHH", "<IIQQQQQQ", (0, 2, 5)), # 64-bit LSB.
6868
(2, 2): (">HHIQQQIHHH", ">IIQQQQQQ", (0, 2, 5)), # 64-bit MSB.
6969
}[(self.capacity, self.encoding)]
70-
except KeyError:
70+
except KeyError as e:
7171
raise ELFInvalid(
7272
f"unrecognized capacity ({self.capacity}) or "
7373
f"encoding ({self.encoding})"
74-
)
74+
) from e
7575

7676
try:
7777
(

setuptools/_vendor/packaging/_manylinux.py

+1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def _parse_glibc_version(version_str: str) -> tuple[int, int]:
164164
f"Expected glibc version with 2 components major.minor,"
165165
f" got: {version_str}",
166166
RuntimeWarning,
167+
stacklevel=2,
167168
)
168169
return -1, -1
169170
return int(m.group("major")), int(m.group("minor"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#######################################################################################
2+
#
3+
# Adapted from:
4+
# https://github.com/pypa/hatch/blob/5352e44/backend/src/hatchling/licenses/parse.py
5+
#
6+
# MIT License
7+
#
8+
# Copyright (c) 2017-present Ofek Lev <[email protected]>
9+
#
10+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this
11+
# software and associated documentation files (the "Software"), to deal in the Software
12+
# without restriction, including without limitation the rights to use, copy, modify,
13+
# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
14+
# permit persons to whom the Software is furnished to do so, subject to the following
15+
# conditions:
16+
#
17+
# The above copyright notice and this permission notice shall be included in all copies
18+
# or substantial portions of the Software.
19+
#
20+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21+
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
22+
# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
24+
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
25+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26+
#
27+
#
28+
# With additional allowance of arbitrary `LicenseRef-` identifiers, not just
29+
# `LicenseRef-Public-Domain` and `LicenseRef-Proprietary`.
30+
#
31+
#######################################################################################
32+
from __future__ import annotations
33+
34+
import re
35+
from typing import NewType, cast
36+
37+
from packaging.licenses._spdx import EXCEPTIONS, LICENSES
38+
39+
__all__ = [
40+
"NormalizedLicenseExpression",
41+
"InvalidLicenseExpression",
42+
"canonicalize_license_expression",
43+
]
44+
45+
license_ref_allowed = re.compile("^[A-Za-z0-9.-]*$")
46+
47+
NormalizedLicenseExpression = NewType("NormalizedLicenseExpression", str)
48+
49+
50+
class InvalidLicenseExpression(ValueError):
51+
"""Raised when a license-expression string is invalid
52+
53+
>>> canonicalize_license_expression("invalid")
54+
Traceback (most recent call last):
55+
...
56+
packaging.licenses.InvalidLicenseExpression: Invalid license expression: 'invalid'
57+
"""
58+
59+
60+
def canonicalize_license_expression(
61+
raw_license_expression: str,
62+
) -> NormalizedLicenseExpression:
63+
if not raw_license_expression:
64+
message = f"Invalid license expression: {raw_license_expression!r}"
65+
raise InvalidLicenseExpression(message)
66+
67+
# Pad any parentheses so tokenization can be achieved by merely splitting on
68+
# whitespace.
69+
license_expression = raw_license_expression.replace("(", " ( ").replace(")", " ) ")
70+
licenseref_prefix = "LicenseRef-"
71+
license_refs = {
72+
ref.lower(): "LicenseRef-" + ref[len(licenseref_prefix) :]
73+
for ref in license_expression.split()
74+
if ref.lower().startswith(licenseref_prefix.lower())
75+
}
76+
77+
# Normalize to lower case so we can look up licenses/exceptions
78+
# and so boolean operators are Python-compatible.
79+
license_expression = license_expression.lower()
80+
81+
tokens = license_expression.split()
82+
83+
# Rather than implementing boolean logic, we create an expression that Python can
84+
# parse. Everything that is not involved with the grammar itself is treated as
85+
# `False` and the expression should evaluate as such.
86+
python_tokens = []
87+
for token in tokens:
88+
if token not in {"or", "and", "with", "(", ")"}:
89+
python_tokens.append("False")
90+
elif token == "with":
91+
python_tokens.append("or")
92+
elif token == "(" and python_tokens and python_tokens[-1] not in {"or", "and"}:
93+
message = f"Invalid license expression: {raw_license_expression!r}"
94+
raise InvalidLicenseExpression(message)
95+
else:
96+
python_tokens.append(token)
97+
98+
python_expression = " ".join(python_tokens)
99+
try:
100+
invalid = eval(python_expression, globals(), locals())
101+
except Exception:
102+
invalid = True
103+
104+
if invalid is not False:
105+
message = f"Invalid license expression: {raw_license_expression!r}"
106+
raise InvalidLicenseExpression(message) from None
107+
108+
# Take a final pass to check for unknown licenses/exceptions.
109+
normalized_tokens = []
110+
for token in tokens:
111+
if token in {"or", "and", "with", "(", ")"}:
112+
normalized_tokens.append(token.upper())
113+
continue
114+
115+
if normalized_tokens and normalized_tokens[-1] == "WITH":
116+
if token not in EXCEPTIONS:
117+
message = f"Unknown license exception: {token!r}"
118+
raise InvalidLicenseExpression(message)
119+
120+
normalized_tokens.append(EXCEPTIONS[token]["id"])
121+
else:
122+
if token.endswith("+"):
123+
final_token = token[:-1]
124+
suffix = "+"
125+
else:
126+
final_token = token
127+
suffix = ""
128+
129+
if final_token.startswith("licenseref-"):
130+
if not license_ref_allowed.match(final_token):
131+
message = f"Invalid licenseref: {final_token!r}"
132+
raise InvalidLicenseExpression(message)
133+
normalized_tokens.append(license_refs[final_token] + suffix)
134+
else:
135+
if final_token not in LICENSES:
136+
message = f"Unknown license: {final_token!r}"
137+
raise InvalidLicenseExpression(message)
138+
normalized_tokens.append(LICENSES[final_token]["id"] + suffix)
139+
140+
normalized_expression = " ".join(normalized_tokens)
141+
142+
return cast(
143+
NormalizedLicenseExpression,
144+
normalized_expression.replace("( ", "(").replace(" )", ")"),
145+
)

0 commit comments

Comments
 (0)