Skip to content

Commit

Permalink
Retain valid names with underscores in egg_info.
Browse files Browse the repository at this point in the history
Closes #2522.
  • Loading branch information
jaraco committed Dec 14, 2023
1 parent dd5f15a commit d0b0a4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions newsfragments/+d4a9206f.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Retain valid names with underscores in egg_info.
4 changes: 3 additions & 1 deletion setuptools/_normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<safe>(?:[0-9]+!)?[0-9]+(?:\.[0-9]+)*)", re.I)

Expand All @@ -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)
Expand Down

0 comments on commit d0b0a4d

Please sign in to comment.