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: