From a60fab3b1f2b6323c99c9d588c97f0efaae85235 Mon Sep 17 00:00:00 2001 From: Alexander Piskun <13381981+bigcat88@users.noreply.github.com> Date: Fri, 28 Jun 2024 10:54:48 +0300 Subject: [PATCH] Parse _version contents instead of using exec() Signed-off-by: Alexander Piskun --- setup.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index b3bf0cee..be7b9b32 100644 --- a/setup.py +++ b/setup.py @@ -24,9 +24,8 @@ class RequiredDependencyException(Exception): def get_version(): """Returns version of the project.""" - version_file = "pillow_heif/_version.py" - exec(compile(Path(version_file).read_text(encoding="utf-8"), version_file, "exec")) # pylint: disable=exec-used - return locals()["__version__"] + match = re.search(r'__version__\s*=\s*"(.*?)"', Path("pillow_heif/_version.py").read_text(encoding="utf-8")) + return match.group(1) def _cmd_exists(cmd: str) -> bool: