From 980437050ef355905fe026c1a5d0e2e8e32fabd0 Mon Sep 17 00:00:00 2001 From: navrkald Date: Tue, 16 Aug 2022 13:42:00 +0200 Subject: [PATCH 1/3] Fixes #920. Don't replace unserscores with hyphens in distribution name. --- tests/test_package.py | 1 + twine/package.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_package.py b/tests/test_package.py index 0b883da3..9ac47fd8 100644 --- a/tests/test_package.py +++ b/tests/test_package.py @@ -121,6 +121,7 @@ def test_package_signed_name_is_correct(): (string.digits, string.digits), (string.punctuation, "-.-"), ("mosaik.SimConfig", "mosaik.SimConfig"), + ("package_name", "package_name"), ("mosaik$$$$.SimConfig", "mosaik-.SimConfig"), ], ) diff --git a/twine/package.py b/twine/package.py index 3ca074fe..7caad349 100644 --- a/twine/package.py +++ b/twine/package.py @@ -51,12 +51,12 @@ def _safe_name(name: str) -> str: """Convert an arbitrary string to a standard distribution name. - Any runs of non-alphanumeric/. characters are replaced with a single '-'. + Any runs of non-alphanumeric/./_ characters are replaced with a single '-'. Copied from pkg_resources.safe_name for compatibility with warehouse. See https://github.com/pypa/twine/issues/743. """ - return re.sub("[^A-Za-z0-9.]+", "-", name) + return re.sub("[^A-Za-z0-9._]+", "-", name) class PackageFile: From e4110305e2becb939b7775f4ee772bc67c00e398 Mon Sep 17 00:00:00 2001 From: navrkald Date: Tue, 16 Aug 2022 14:18:13 +0200 Subject: [PATCH 2/3] Fix the tests. --- tests/test_package.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/test_package.py b/tests/test_package.py index 9ac47fd8..9c5e4f46 100644 --- a/tests/test_package.py +++ b/tests/test_package.py @@ -119,9 +119,8 @@ def test_package_signed_name_is_correct(): [ (string.ascii_letters, string.ascii_letters), (string.digits, string.digits), - (string.punctuation, "-.-"), - ("mosaik.SimConfig", "mosaik.SimConfig"), - ("package_name", "package_name"), + (string.punctuation, "-.-_-"), + ("mosaik._SimConfig", "mosaik._SimConfig"), ("mosaik$$$$.SimConfig", "mosaik-.SimConfig"), ], ) From ab736026adfb0a1281ad0a62aeaabf495dc20fcf Mon Sep 17 00:00:00 2001 From: navrkald Date: Tue, 16 Aug 2022 14:21:57 +0200 Subject: [PATCH 3/3] doc: #901 - Added change log. --- changelog/901.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/901.bugfix.rst diff --git a/changelog/901.bugfix.rst b/changelog/901.bugfix.rst new file mode 100644 index 00000000..cfd7e81b --- /dev/null +++ b/changelog/901.bugfix.rst @@ -0,0 +1 @@ +Fixed replacing underscores by hyphens in package names. \ No newline at end of file