Skip to content

Commit

Permalink
Merge pull request #1 from julienmalard/patch-2
Browse files Browse the repository at this point in the history
Fix for unicode identifiers
  • Loading branch information
julienmalard authored Dec 14, 2024
2 parents 660cf99 + adb6193 commit 6971418
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions src/installer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,6 @@
"WheelFilename", ["distribution", "version", "build_tag", "tag"]
)

# Adapted from https://github.com/python/importlib_metadata/blob/v3.4.0/importlib_metadata/__init__.py#L90
_ENTRYPOINT_REGEX = re.compile(
r"""
(?P<module>[\w.]+)\s*
(:\s*(?P<attrs>[\w.]+))\s*
(?P<extras>\[.*\])?\s*$
""",
re.VERBOSE | re.UNICODE,
)

# According to https://www.python.org/dev/peps/pep-0427/#id7
SCHEME_NAMES = cast(AllSchemes, ("purelib", "platlib", "headers", "scripts", "data"))

Expand Down Expand Up @@ -244,16 +234,14 @@ def parse_entrypoints(text: str) -> Iterable[tuple[str, str, str, "ScriptSection

for name, value in config.items(section):
assert isinstance(name, str)
match = _ENTRYPOINT_REGEX.match(value)
assert match
assert ":" in value

module = match.group("module")
assert isinstance(module, str)
module, attrs = [x.strip() for x in value.split(":", 1)]
assert len(module)

attrs = match.group("attrs")
# TODO: make this a proper error, which can be caught.
assert attrs is not None
assert isinstance(attrs, str)
assert len(attrs)
assert all(x.isidentifier() for x in attrs.split("."))

script_section = cast("ScriptSection", section[: -len("_scripts")])

Expand Down

0 comments on commit 6971418

Please sign in to comment.