Skip to content

Commit 348c428

Browse files
authored
Merge pull request #12939 from notatallshaw/update-non-PEP-440-wheel-filename-deprecation-notice
Update non PEP 440 wheel filename deprecation notice
2 parents 0330f95 + 0c4cdf9 commit 348c428

File tree

2 files changed

+42
-14
lines changed

2 files changed

+42
-14
lines changed

news/12939.trivial.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update non PEP 440 wheel filename deprecation notice.

src/pip/_internal/models/wheel.py

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
from typing import Dict, Iterable, List
77

88
from pip._vendor.packaging.tags import Tag
9+
from pip._vendor.packaging.utils import (
10+
InvalidVersion,
11+
parse_wheel_filename,
12+
)
13+
from pip._vendor.packaging.utils import (
14+
InvalidWheelFilename as PackagingInvalidWheelName,
15+
)
916

1017
from pip._internal.exceptions import InvalidWheelFilename
1118
from pip._internal.utils.deprecation import deprecated
@@ -32,20 +39,40 @@ def __init__(self, filename: str) -> None:
3239
self.name = wheel_info.group("name").replace("_", "-")
3340
_version = wheel_info.group("ver")
3441
if "_" in _version:
35-
deprecated(
36-
reason=(
37-
f"Wheel filename {filename!r} uses an invalid filename format, "
38-
f"as the version part {_version!r} is not correctly normalised, "
39-
"and contains an underscore character. Future versions of pip may "
40-
"fail to recognise this wheel."
41-
),
42-
replacement=(
43-
"rename the wheel to use a correctly normalised version part "
44-
"(this may require updating the version in the project metadata)"
45-
),
46-
gone_in="25.1",
47-
issue=12914,
48-
)
42+
try:
43+
parse_wheel_filename(filename)
44+
except InvalidVersion as e:
45+
deprecated(
46+
reason=(
47+
f"Wheel filename version part {_version!r} is not correctly "
48+
"normalised, and contained an underscore character in the "
49+
"version part. Future versions of pip will fail to recognise "
50+
f"this wheel and report the error: {e.args[0]}."
51+
),
52+
replacement=(
53+
"rename the wheel to use a correctly normalised "
54+
"version part (this may require updating the version "
55+
"in the project metadata)"
56+
),
57+
gone_in="25.1",
58+
issue=12938,
59+
)
60+
except PackagingInvalidWheelName as e:
61+
deprecated(
62+
reason=(
63+
f"The wheel filename {filename!r} is not correctly normalised. "
64+
"Future versions of pip will fail to recognise this wheel. "
65+
f"and report the error: {e.args[0]}."
66+
),
67+
replacement=(
68+
"rename the wheel to use a correctly normalised "
69+
"name (this may require updating the version in "
70+
"the project metadata)"
71+
),
72+
gone_in="25.1",
73+
issue=12938,
74+
)
75+
4976
_version = _version.replace("_", "-")
5077

5178
self.version = _version

0 commit comments

Comments
 (0)