Skip to content

Commit

Permalink
fix (utils.patterns): recognize one digit version in filename
Browse files Browse the repository at this point in the history
fix (utils.patterns): version part in filename must be present according PEP491
  • Loading branch information
finswimmer committed Feb 14, 2021
1 parent a4d42a3 commit 959d2cd
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
9 changes: 6 additions & 3 deletions poetry/utils/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@


wheel_file_re = re.compile(
r"""^(?P<namever>(?P<name>.+?)(-(?P<ver>\d.+?))?)
((-(?P<build>\d.*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)
\.whl|\.dist-info)$""",
r"^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?))"
r"(-(?P<build>\d.*?))?"
r"-(?P<pyver>.+?)"
r"-(?P<abi>.+?)"
r"-(?P<plat>.+?)"
r"\.whl|\.dist-info$",
re.VERBOSE,
)
39 changes: 39 additions & 0 deletions tests/utils/test_patterns.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import pytest

from poetry.utils import patterns


@pytest.mark.parametrize(
["filename", "expected"],
[
(
"markdown_captions-2-py3-none-any.whl",
{
"namever": "markdown_captions-2",
"name": "markdown_captions",
"ver": "2",
"build": None,
"pyver": "py3",
"abi": "none",
"plat": "any",
},
),
(
"SQLAlchemy-1.3.20-cp27-cp27mu-manylinux2010_x86_64.whl",
{
"namever": "SQLAlchemy-1.3.20",
"name": "SQLAlchemy",
"ver": "1.3.20",
"build": None,
"pyver": "cp27",
"abi": "cp27mu",
"plat": "manylinux2010_x86_64",
},
),
],
)
def test_wheel_file_re(filename, expected):
match = patterns.wheel_file_re.match(filename)
groups = match.groupdict()

assert groups == expected

0 comments on commit 959d2cd

Please sign in to comment.