Skip to content

Commit 355ac95

Browse files
authored
fix(utils.patterns): recognize one digit version in filename (#3866)
fix(utils.patterns): version part in filename must be present according PEP491
1 parent 9ba25bc commit 355ac95

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

poetry/utils/patterns.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33

44
wheel_file_re = re.compile(
5-
r"""^(?P<namever>(?P<name>.+?)(-(?P<ver>\d.+?))?)
6-
((-(?P<build>\d.*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)
7-
\.whl|\.dist-info)$""",
5+
r"^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?))"
6+
r"(-(?P<build>\d.*?))?"
7+
r"-(?P<pyver>.+?)"
8+
r"-(?P<abi>.+?)"
9+
r"-(?P<plat>.+?)"
10+
r"\.whl|\.dist-info$",
811
re.VERBOSE,
912
)

tests/utils/test_patterns.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import pytest
2+
3+
from poetry.utils import patterns
4+
5+
6+
@pytest.mark.parametrize(
7+
["filename", "expected"],
8+
[
9+
(
10+
"markdown_captions-2-py3-none-any.whl",
11+
{
12+
"namever": "markdown_captions-2",
13+
"name": "markdown_captions",
14+
"ver": "2",
15+
"build": None,
16+
"pyver": "py3",
17+
"abi": "none",
18+
"plat": "any",
19+
},
20+
),
21+
(
22+
"SQLAlchemy-1.3.20-cp27-cp27mu-manylinux2010_x86_64.whl",
23+
{
24+
"namever": "SQLAlchemy-1.3.20",
25+
"name": "SQLAlchemy",
26+
"ver": "1.3.20",
27+
"build": None,
28+
"pyver": "cp27",
29+
"abi": "cp27mu",
30+
"plat": "manylinux2010_x86_64",
31+
},
32+
),
33+
],
34+
)
35+
def test_wheel_file_re(filename, expected):
36+
match = patterns.wheel_file_re.match(filename)
37+
groups = match.groupdict()
38+
39+
assert groups == expected

0 commit comments

Comments
 (0)