Skip to content

Commit d0b0a4d

Browse files
committed
Retain valid names with underscores in egg_info.
Closes #2522.
1 parent dd5f15a commit d0b0a4d

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

newsfragments/+d4a9206f.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Retain valid names with underscores in egg_info.

setuptools/_normalization.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# https://packaging.python.org/en/latest/specifications/core-metadata/#name
1414
_VALID_NAME = re.compile(r"^([A-Z0-9]|[A-Z0-9][A-Z0-9._-]*[A-Z0-9])$", re.I)
15-
_UNSAFE_NAME_CHARS = re.compile(r"[^A-Z0-9.]+", re.I)
15+
_UNSAFE_NAME_CHARS = re.compile(r"[^A-Z0-9._-]+", re.I)
1616
_NON_ALPHANUMERIC = re.compile(r"[^A-Z0-9]+", re.I)
1717
_PEP440_FALLBACK = re.compile(r"^v?(?P<safe>(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)", re.I)
1818

@@ -35,6 +35,8 @@ def safe_name(component: str) -> str:
3535
'hello-world'
3636
>>> safe_name("hello?world")
3737
'hello-world'
38+
>>> safe_name("hello_world")
39+
'hello_world'
3840
"""
3941
# See pkg_resources.safe_name
4042
return _UNSAFE_NAME_CHARS.sub("-", component)

0 commit comments

Comments
 (0)