diff --git a/poetry/packages/__init__.py b/poetry/packages/__init__.py index caa9c1c28a6..e0a2203c9d3 100644 --- a/poetry/packages/__init__.py +++ b/poetry/packages/__init__.py @@ -2,6 +2,7 @@ import re from poetry.semver import Version +from poetry.utils.patterns import wheel_file_re from poetry.version.requirements import Requirement from .dependency import Dependency @@ -70,7 +71,7 @@ def dependency_from_pep_508(name): link = Link(path_to_url(os.path.normpath(os.path.abspath(link.path)))) # wheel file if link.is_wheel: - m = re.match(r"^(?P(?P.+?)-(?P\d.*?))", link.filename) + m = wheel_file_re.match(link.filename) if not m: raise ValueError("Invalid wheel name: {}".format(link.filename)) diff --git a/tests/packages/test_main.py b/tests/packages/test_main.py index 7cc93397f0d..586be5a31b8 100644 --- a/tests/packages/test_main.py +++ b/tests/packages/test_main.py @@ -191,3 +191,14 @@ def test_dependency_from_pep_508_with_url(): assert "django-utils" == dep.name assert dep.is_url() assert "https://example.com/django-utils-1.0.0.tar.gz" == dep.url + + +def test_dependency_from_pep_508_with_wheel_url(): + name = ( + "example_wheel @ https://example.com/example_wheel-14.0.2-py2.py3-none-any.whl" + ) + + dep = dependency_from_pep_508(name) + + assert "example-wheel" == dep.name + assert str(dep.constraint) == "14.0.2"