diff --git a/src/poetry/utils/patterns.py b/src/poetry/utils/patterns.py index bf88e51b9bf..717a569ddcd 100644 --- a/src/poetry/utils/patterns.py +++ b/src/poetry/utils/patterns.py @@ -14,6 +14,6 @@ ) sdist_file_re = re.compile( - r"^(?P(?P.+?)-(?P\d.*?))" + r"^(?P(?P.+?)-(?P\d[^-]*?))" r"(\.sdist)?\.(?P(zip|tar(\.(gz|bz2|xz|Z))?))$" ) diff --git a/tests/utils/test_patterns.py b/tests/utils/test_patterns.py index 87abb287219..f3df7d52be6 100644 --- a/tests/utils/test_patterns.py +++ b/tests/utils/test_patterns.py @@ -40,3 +40,34 @@ def test_wheel_file_re(filename: str, expected: dict[str, str | None]) -> None: groups = match.groupdict() assert groups == expected + + +@pytest.mark.parametrize( + ["filename", "expected"], + [ + ( + "poetry_core-1.5.0.tar.gz", + { + "namever": "poetry_core-1.5.0", + "name": "poetry_core", + "ver": "1.5.0", + "format": "tar.gz", + }, + ), + ( + "flask-restful-swagger-2-0.35.tar.gz", + { + "namever": "flask-restful-swagger-2-0.35", + "name": "flask-restful-swagger-2", + "ver": "0.35", + "format": "tar.gz", + }, + ), + ], +) +def test_sdist_file_re(filename: str, expected: dict[str, str | None]) -> None: + match = patterns.sdist_file_re.match(filename) + assert match is not None + groups = match.groupdict() + + assert groups == expected