File tree 3 files changed +24
-5
lines changed
3 files changed +24
-5
lines changed Original file line number Diff line number Diff line change
1
+ Deprecate wheel filenames that are not compliant with PEP 440.
Original file line number Diff line number Diff line change 8
8
from pip ._vendor .packaging .tags import Tag
9
9
10
10
from pip ._internal .exceptions import InvalidWheelFilename
11
+ from pip ._internal .utils .deprecation import deprecated
11
12
12
13
13
14
class Wheel :
@@ -29,9 +30,25 @@ def __init__(self, filename: str) -> None:
29
30
raise InvalidWheelFilename (f"{ filename } is not a valid wheel filename." )
30
31
self .filename = filename
31
32
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
35
52
self .build_tag = wheel_info .group ("build" )
36
53
self .pyversions = wheel_info .group ("pyver" ).split ("." )
37
54
self .abis = wheel_info .group ("abi" ).split ("." )
Original file line number Diff line number Diff line change 3
3
4
4
from pip ._internal .exceptions import InvalidWheelFilename
5
5
from pip ._internal .models .wheel import Wheel
6
- from pip ._internal .utils import compatibility_tags
6
+ from pip ._internal .utils import compatibility_tags , deprecation
7
7
8
8
9
9
class TestWheelFile :
@@ -175,5 +175,6 @@ def test_version_underscore_conversion(self) -> None:
175
175
Test that we convert '_' to '-' for versions parsed out of wheel
176
176
filenames
177
177
"""
178
- w = Wheel ("simple-0.1_1-py2-none-any.whl" )
178
+ with pytest .warns (deprecation .PipDeprecationWarning ):
179
+ w = Wheel ("simple-0.1_1-py2-none-any.whl" )
179
180
assert w .version == "0.1-1"
You can’t perform that action at this time.
0 commit comments