Skip to content

Commit

Permalink
Parse _version contents instead of using exec()
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
  • Loading branch information
bigcat88 committed Jun 28, 2024
1 parent 5459857 commit a60fab3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a60fab3

Please sign in to comment.