Skip to content

Commit 7f987b3

Browse files
committed
Depricate '_' in version of wheel filename
1 parent 858a515 commit 7f987b3

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/pip/_internal/models/wheel.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pip._vendor.packaging.tags import Tag
99

1010
from pip._internal.exceptions import InvalidWheelFilename
11+
from pip._internal.utils.deprecation import deprecated
1112

1213

1314
class Wheel:
@@ -29,9 +30,25 @@ def __init__(self, filename: str) -> None:
2930
raise InvalidWheelFilename(f"{filename} is not a valid wheel filename.")
3031
self.filename = filename
3132
self.name = wheel_info.group("name").replace("_", "-")
32-
# we'll assume "_" means "-" due to wheel naming scheme
33-
# (https://github.com/pypa/pip/issues/1150)
34-
self.version = wheel_info.group("ver").replace("_", "-")
33+
_version = wheel_info.group("ver")
34+
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+
)
49+
_version = _version.replace("_", "-")
50+
51+
self.version = _version
3552
self.build_tag = wheel_info.group("build")
3653
self.pyversions = wheel_info.group("pyver").split(".")
3754
self.abis = wheel_info.group("abi").split(".")

0 commit comments

Comments
 (0)