diff --git a/pylib/anki/buildinfo.py b/pylib/anki/buildinfo.py index bb388d5be..b7f377e1c 100644 --- a/pylib/anki/buildinfo.py +++ b/pylib/anki/buildinfo.py @@ -1,26 +1,12 @@ # Copyright: Ankitects Pty Ltd and contributors # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html -import os -import sys - - -def _build_info_path() -> str: - path = os.path.join(os.path.dirname(__file__), "buildinfo.txt") - # running in place? - if os.path.exists(path): - return path - # packaged build? - path = os.path.join(sys.prefix, "buildinfo.txt") - if os.path.exists(path): - return path - - raise Exception("missing buildinfo.txt") +from importlib.resources import open_text def _get_build_info() -> dict[str, str]: info = {} - with open(_build_info_path(), encoding="utf8") as file: + with open_text("anki", "buildinfo.txt") as file: for line in file.readlines(): elems = line.split() if len(elems) == 2: