From c6c7519d49fde4be41667922c01924a1ea3bd13c Mon Sep 17 00:00:00 2001 From: David Hilton Date: Tue, 24 Nov 2020 12:46:36 -0500 Subject: [PATCH] allow Wheel to work when no version is specified in filename See #3411 --- poetry/installation/chooser.py | 4 +++- tests/installation/test_chooser.py | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/poetry/installation/chooser.py b/poetry/installation/chooser.py index 6d9e92e0b1f..4e2a6d221a1 100644 --- a/poetry/installation/chooser.py +++ b/poetry/installation/chooser.py @@ -24,7 +24,9 @@ def __init__(self, filename): # type: (str) -> None self.filename = filename self.name = wheel_info.group("name").replace("_", "-") - self.version = wheel_info.group("ver").replace("_", "-") + self.version = wheel_info.group("ver") + if self.version: + self.version = self.version.replace("_", "-") self.build_tag = wheel_info.group("build") self.pyversions = wheel_info.group("pyver").split(".") self.abis = wheel_info.group("abi").split(".") diff --git a/tests/installation/test_chooser.py b/tests/installation/test_chooser.py index 75fd52c7926..a6a2e32f669 100644 --- a/tests/installation/test_chooser.py +++ b/tests/installation/test_chooser.py @@ -8,6 +8,7 @@ from poetry.core.packages.package import Package from poetry.installation.chooser import Chooser +from poetry.installation.chooser import Wheel from poetry.repositories.legacy_repository import LegacyRepository from poetry.repositories.pool import Pool from poetry.repositories.pypi_repository import PyPiRepository @@ -196,3 +197,7 @@ def test_chooser_chooses_distributions_that_match_the_package_hashes( link = chooser.choose_for(package) assert "isort-4.3.4.tar.gz" == link.filename + + +def test_wheel_handles_no_version(env, pool): + Wheel("tiamat-6-py3-none-any.whl")