Skip to content

Commit aa25c97

Browse files
committed
Update non PEP 440 wheel filename deprecation notice
1 parent 81041f7 commit aa25c97

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

src/pip/_internal/models/wheel.py

Lines changed: 26 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,22 +39,27 @@ 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-
)
4942
_version = _version.replace("_", "-")
5043

44+
try:
45+
parse_wheel_filename(filename)
46+
except (PackagingInvalidWheelName, InvalidVersion):
47+
deprecated(
48+
reason=(
49+
f"Wheel filename {filename!r} uses an invalid filename format, "
50+
f"as the version part {_version!r} is not correctly "
51+
"normalised, and contains an underscore character. Future "
52+
"versions of pip will fail to recognise this wheel."
53+
),
54+
replacement=(
55+
"rename the wheel to use a correctly normalised "
56+
"version part (this may require updating the version "
57+
"in the project metadata)"
58+
),
59+
gone_in="25.1",
60+
issue=12938,
61+
)
62+
5163
self.version = _version
5264
self.build_tag = wheel_info.group("build")
5365
self.pyversions = wheel_info.group("pyver").split(".")

0 commit comments

Comments
 (0)