Skip to content

Commit 61cbca0

Browse files
committed
Remove legacy wheel filename support
1 parent 81b3c05 commit 61cbca0

File tree

1 file changed

+5
-66
lines changed

1 file changed

+5
-66
lines changed

src/pip/_internal/models/wheel.py

Lines changed: 5 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,91 +4,30 @@
44

55
from __future__ import annotations
66

7-
import re
87
from collections.abc import Iterable
98

109
from pip._vendor.packaging.tags import Tag
11-
from pip._vendor.packaging.utils import BuildTag, parse_wheel_filename
1210
from pip._vendor.packaging.utils import (
1311
InvalidWheelFilename as _PackagingInvalidWheelFilename,
1412
)
13+
from pip._vendor.packaging.utils import parse_wheel_filename
1514

1615
from pip._internal.exceptions import InvalidWheelFilename
17-
from pip._internal.utils.deprecation import deprecated
1816

1917

2018
class Wheel:
2119
"""A wheel file"""
2220

23-
legacy_wheel_file_re = re.compile(
24-
r"""^(?P<namever>(?P<name>[^\s-]+?)-(?P<ver>[^\s-]*?))
25-
((-(?P<build>\d[^-]*?))?-(?P<pyver>[^\s-]+?)-(?P<abi>[^\s-]+?)-(?P<plat>[^\s-]+?)
26-
\.whl|\.dist-info)$""",
27-
re.VERBOSE,
28-
)
29-
3021
def __init__(self, filename: str) -> None:
3122
self.filename = filename
3223

33-
# To make mypy happy specify type hints that can come from either
34-
# parse_wheel_filename or the legacy_wheel_file_re match.
35-
self.name: str
36-
self._build_tag: BuildTag | None = None
37-
3824
try:
3925
wheel_info = parse_wheel_filename(filename)
40-
self.name, _version, self._build_tag, self.file_tags = wheel_info
41-
self.version = str(_version)
4226
except _PackagingInvalidWheelFilename as e:
43-
# Check if the wheel filename is in the legacy format
44-
legacy_wheel_info = self.legacy_wheel_file_re.match(filename)
45-
if not legacy_wheel_info:
46-
raise InvalidWheelFilename(e.args[0]) from None
47-
48-
deprecated(
49-
reason=(
50-
f"Wheel filename {filename!r} is not correctly normalised. "
51-
"Future versions of pip will raise the following error:\n"
52-
f"{e.args[0]}\n\n"
53-
),
54-
replacement=(
55-
"to rename the wheel to use a correctly normalised "
56-
"name (this may require updating the version in "
57-
"the project metadata)"
58-
),
59-
gone_in="25.3",
60-
issue=12938,
61-
)
62-
63-
self.name = legacy_wheel_info.group("name").replace("_", "-")
64-
self.version = legacy_wheel_info.group("ver").replace("_", "-")
65-
66-
# Generate the file tags from the legacy wheel filename
67-
pyversions = legacy_wheel_info.group("pyver").split(".")
68-
abis = legacy_wheel_info.group("abi").split(".")
69-
plats = legacy_wheel_info.group("plat").split(".")
70-
self.file_tags = frozenset(
71-
Tag(interpreter=py, abi=abi, platform=plat)
72-
for py in pyversions
73-
for abi in abis
74-
for plat in plats
75-
)
76-
77-
@property
78-
def build_tag(self) -> BuildTag:
79-
if self._build_tag is not None:
80-
return self._build_tag
81-
82-
# Parse the build tag from the legacy wheel filename
83-
legacy_wheel_info = self.legacy_wheel_file_re.match(self.filename)
84-
assert legacy_wheel_info is not None, "guaranteed by filename validation"
85-
build_tag = legacy_wheel_info.group("build")
86-
match = re.match(r"^(\d+)(.*)$", build_tag)
87-
assert match is not None, "guaranteed by filename validation"
88-
build_tag_groups = match.groups()
89-
self._build_tag = (int(build_tag_groups[0]), build_tag_groups[1])
90-
91-
return self._build_tag
27+
raise InvalidWheelFilename(e.args[0]) from None
28+
29+
self.name, _version, self.build_tag, self.file_tags = wheel_info
30+
self.version = str(_version)
9231

9332
def get_formatted_file_tags(self) -> list[str]:
9433
"""Return the wheel's tags as a sorted list of strings."""

0 commit comments

Comments
 (0)