Skip to content

Commit

Permalink
fixed base_path function
Browse files Browse the repository at this point in the history
  • Loading branch information
DJSchaffner committed Apr 18, 2024
1 parent 17034ae commit d515b22
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit d515b22

Please sign in to comment.