From 23e40b6988ae279605c2032574357646672e59ad Mon Sep 17 00:00:00 2001 From: Mathieu Kniewallner Date: Mon, 6 Jun 2022 15:54:29 +0200 Subject: [PATCH] feat(masonry): follow newer PyPA specification for wheel name As per https://packaging.python.org/en/latest/specifications/binary-distribution-format/#binary-distribution-format, the specification replaces the original PEP 427 specification. The specification for the distribution name is https://packaging.python.org/en/latest/specifications/binary-distribution-format/#escaping-and-unicode. --- src/poetry/core/masonry/utils/helpers.py | 4 ++-- tests/masonry/utils/test_helpers.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/poetry/core/masonry/utils/helpers.py b/src/poetry/core/masonry/utils/helpers.py index 1dddfa51a..f14440a15 100644 --- a/src/poetry/core/masonry/utils/helpers.py +++ b/src/poetry/core/masonry/utils/helpers.py @@ -29,5 +29,5 @@ def escape_version(version: str) -> str: def escape_name(name: str) -> str: - """Escaped wheel name as specified in :pep:`427#escaping-and-unicode`.""" - return re.sub(r"[^\w\d.]+", "_", name, flags=re.UNICODE) + """Escaped wheel name as specified in https://packaging.python.org/en/latest/specifications/binary-distribution-format/#escaping-and-unicode.""" + return re.sub(r"[-_.]+", "_", name, flags=re.UNICODE).lower() diff --git a/tests/masonry/utils/test_helpers.py b/tests/masonry/utils/test_helpers.py index d21bc975a..8be13c40a 100644 --- a/tests/masonry/utils/test_helpers.py +++ b/tests/masonry/utils/test_helpers.py @@ -28,9 +28,9 @@ def test_escape_version(version: str, expected: str) -> None: [ ("foo", "foo"), ("foo-bar", "foo_bar"), - ("FOO-bAr", "FOO_bAr"), - ("foo.bar", "foo.bar"), - ("foo123-ba---.r", "foo123_ba_.r"), + ("FOO-bAr", "foo_bar"), + ("foo.bar", "foo_bar"), + ("foo123-ba---.r", "foo123_ba_r"), ], ) def test_escape_name(name: str, expected: str) -> None: