From adb619382ca94d373def192e35f13077bd66c6b0 Mon Sep 17 00:00:00 2001 From: Julien Malard-Adam Date: Sat, 14 Dec 2024 09:48:45 +0530 Subject: [PATCH] Fix for unicode identifiers --- src/installer/utils.py | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/installer/utils.py b/src/installer/utils.py index 7df3e05..61cec2d 100644 --- a/src/installer/utils.py +++ b/src/installer/utils.py @@ -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[\w.]+)\s* - (:\s*(?P[\w.]+))\s* - (?P\[.*\])?\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")) @@ -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")])