From d515b2264be0bff45d1f4cfb04b6ea3189a6b329 Mon Sep 17 00:00:00 2001 From: DJSchaffner Date: Thu, 18 Apr 2024 20:28:15 +0200 Subject: [PATCH] fixed base_path function --- src/utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/utils.py b/src/utils.py index 0b1ee52..4206d44 100644 --- a/src/utils.py +++ b/src/utils.py @@ -145,11 +145,15 @@ def base_path(): Returns: pathlib.Path: The base path of the executable or project """ - # Check for compiled version - if getattr(sys, 'frozen', False) or hasattr(sys, '_MEIPASS'): + # Check for compiled version via pyinstaller or similar + if getattr(sys, 'frozen', False): + return pathlib.Path(pathlib.sys._MEIPASS) + # Check for nuitka + elif "__compiled__" in globals() or hasattr(sys, 'nuitka_version_info'): return pathlib.Path(pathlib.sys.executable).parent + # Running as script (expects to be inside root/src) else: - return pathlib.Path(__file__).resolve().parent.parent + return pathlib.Path(__file__).parent.parent def resource_path(relative_path: str):