Install wheel with a non-PEP 440 version in the filename.

PEP 427 has no specific requirements for the format of the version.
As pip wheel allows to create a wheel with a non-PEP 440 version,
it should also be able to install that same wheel.
This commit is contained in:
Vincent Philippon 2017-03-27 22:49:21 -04:00
parent b9f70f2061
commit 8378567b61
5 changed files with 19 additions and 2 deletions

1
news/4169.bugfix Normal file
View File

@ -0,0 +1 @@
Support the installation of wheels with non-PEP 440 version in their filenames.

View File

@ -187,7 +187,7 @@ def fix_script(path):
script.write(rest)
return True
dist_info_re = re.compile(r"""^(?P<namever>(?P<name>.+?)(-(?P<ver>\d.+?))?)
dist_info_re = re.compile(r"""^(?P<namever>(?P<name>.+?)(-(?P<ver>.+?))?)
\.dist-info$""", re.VERBOSE)
@ -582,7 +582,7 @@ class Wheel(object):
# TODO: maybe move the install code into this class
wheel_file_re = re.compile(
r"""^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?))
r"""^(?P<namever>(?P<name>.+?)-(?P<ver>.*?))
((-(?P<build>\d.*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)
\.whl|\.dist-info)$""",
re.VERBOSE

View File

@ -0,0 +1,4 @@
Wheel-Version: 0.1
Packager: bdist_wheel
Root-Is-Purelib: false

View File

@ -0,0 +1,4 @@
Wheel-Version: 0.1
Packager: bdist_wheel
Root-Is-Purelib: true

View File

@ -100,6 +100,10 @@ class TestWheelFile(object):
w = wheel.Wheel('simple-1-py2-none-any.whl')
assert w.version == '1'
def test_non_pep440_version(self):
w = wheel.Wheel('simple-_invalid_-py2-none-any.whl')
assert w.version == '-invalid-'
def test_missing_version_raises(self):
with pytest.raises(InvalidWheelFilename):
wheel.Wheel('Cython-cp27-none-linux_x86_64.whl')
@ -257,6 +261,10 @@ class TestWheelFile(object):
packages = [
("pure_wheel", data.packages.join("pure_wheel-1.7"), True),
("plat_wheel", data.packages.join("plat_wheel-1.7"), False),
("pure_wheel", data.packages.join(
"pure_wheel-_invalidversion_"), True),
("plat_wheel", data.packages.join(
"plat_wheel-_invalidversion_"), False),
]
for name, path, expected in packages: