Skip to content

Commit

Permalink
Use 'resolve' instead of 'absolute' for obtaining absolute paths;
Browse files Browse the repository at this point in the history
gui.py GUI debug now redirects SELF_PATH to main.py as well
  • Loading branch information
DevilXD committed Oct 27, 2024
1 parent eae23e3 commit d8687b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import sys
from pathlib import Path
from typing import Any, TYPE_CHECKING

SELF_PATH = str(Path(".").absolute())
SELF_PATH = str(Path(".").resolve())
if SELF_PATH not in sys.path:
sys.path.insert(0, SELF_PATH)

Expand Down
15 changes: 8 additions & 7 deletions constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _resource_path(relative_path: Path | str) -> Path:
Works for dev and for PyInstaller.
"""
if IS_APPIMAGE:
base_path = Path(sys.argv[0]).absolute().parent
base_path = Path(sys.argv[0]).resolve().parent
elif IS_PACKAGED:
# PyInstaller's folder where the one-file app is unpacked
meipass: str = getattr(sys, "_MEIPASS")
Expand Down Expand Up @@ -78,13 +78,14 @@ def _merge_vars(base_vars: JsonType, vars: JsonType) -> None:

# Base Paths
if IS_APPIMAGE:
SELF_PATH = Path(os.environ["APPIMAGE"]).absolute()
SELF_PATH = Path(os.environ["APPIMAGE"]).resolve()
else:
# NOTE: pyinstaller will set sys.argv[0] to its own executable when building,
# detect this to use __file__ and main.py redirection instead
SELF_PATH = Path(sys.argv[0]).absolute()
if SELF_PATH.stem == "pyinstaller":
SELF_PATH = Path(__file__).with_name("main.py").absolute()
# NOTE: pyinstaller will set sys.argv[0] to its own executable when building
# NOTE: sys.argv[0] will point to gui.py when running the gui.py directly for GUI debug
# detect these and use __file__ and main.py redirection instead
SELF_PATH = Path(sys.argv[0]).resolve()
if SELF_PATH.stem == "pyinstaller" or SELF_PATH.name == "gui.py":
SELF_PATH = Path(__file__).with_name("main.py").resolve()
WORKING_DIR = SELF_PATH.parent
# Development paths
VENV_PATH = Path(WORKING_DIR, "env")
Expand Down

0 comments on commit d8687b6

Please sign in to comment.