Skip to content

Commit

Permalink
fix: correct parsing of wheel version with regex. (#1932)
Browse files Browse the repository at this point in the history
The previous regexp was only taking the first integer of the version number,
this presented problems when the major version number reached double digits.

Poetry would determine that the version of the dependency is '1', rather than,
ie: '14'. This caused failures to solve versions.
  • Loading branch information
edwardgeorge authored and sdispater committed Jan 22, 2020
1 parent 2df0d2c commit 930515b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion poetry/packages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<namever>(?P<name>.+?)-(?P<ver>\d.*?))", link.filename)
m = wheel_file_re.match(link.filename)
if not m:
raise ValueError("Invalid wheel name: {}".format(link.filename))

Expand Down
11 changes: 11 additions & 0 deletions tests/packages/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 930515b

Please sign in to comment.