From d5f7944b097cc2d3d7c3edaa043f9ed63b80fb57 Mon Sep 17 00:00:00 2001 From: finswimmer Date: Sat, 7 Nov 2020 15:42:57 +0100 Subject: [PATCH] fix (utils.patterns): recognize one digit version in filename fix (utils.patterns): version part in filename must be present according PEP491 --- poetry/utils/patterns.py | 9 ++++++--- tests/utils/test_patterns.py | 39 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 tests/utils/test_patterns.py diff --git a/poetry/utils/patterns.py b/poetry/utils/patterns.py index 1d6413c26fe..ec6c53d78d7 100644 --- a/poetry/utils/patterns.py +++ b/poetry/utils/patterns.py @@ -2,8 +2,11 @@ wheel_file_re = re.compile( - r"""^(?P(?P.+?)(-(?P\d.+?))?) - ((-(?P\d.*?))?-(?P.+?)-(?P.+?)-(?P.+?) - \.whl|\.dist-info)$""", + r"^(?P(?P.+?)-(?P\d.*?))" + r"(-(?P\d.*?))?" + r"-(?P.+?)" + r"-(?P.+?)" + r"-(?P.+?)" + r"\.whl|\.dist-info$", re.VERBOSE, ) diff --git a/tests/utils/test_patterns.py b/tests/utils/test_patterns.py new file mode 100644 index 00000000000..9f43db27c56 --- /dev/null +++ b/tests/utils/test_patterns.py @@ -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