diff --git a/newsfragments/+d4a9206f.bugfix.rst b/newsfragments/+d4a9206f.bugfix.rst new file mode 100644 index 0000000000..b066641029 --- /dev/null +++ b/newsfragments/+d4a9206f.bugfix.rst @@ -0,0 +1 @@ +Retain valid names with underscores in egg_info. \ No newline at end of file diff --git a/setuptools/_normalization.py b/setuptools/_normalization.py index eee4fb7746..aa9274f093 100644 --- a/setuptools/_normalization.py +++ b/setuptools/_normalization.py @@ -12,7 +12,7 @@ # https://packaging.python.org/en/latest/specifications/core-metadata/#name _VALID_NAME = re.compile(r"^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$", re.I) -_UNSAFE_NAME_CHARS = re.compile(r"[^A-Z0-9.]+", re.I) +_UNSAFE_NAME_CHARS = re.compile(r"[^A-Z0-9._-]+", re.I) _NON_ALPHANUMERIC = re.compile(r"[^A-Z0-9]+", re.I) _PEP440_FALLBACK = re.compile(r"^v?(?P(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)", re.I) @@ -35,6 +35,8 @@ def safe_name(component: str) -> str: 'hello-world' >>> safe_name("hello?world") 'hello-world' + >>> safe_name("hello_world") + 'hello_world' """ # See pkg_resources.safe_name return _UNSAFE_NAME_CHARS.sub("-", component)