|
@@ -39,7 +39,18 @@ def get_app_dir() -> Path:
|
|
|
"""
|
|
"""
|
|
|
try:
|
|
try:
|
|
|
if getattr(sys, "frozen", False):
|
|
if getattr(sys, "frozen", False):
|
|
|
- return Path(sys.executable).resolve().parent
|
|
|
|
|
|
|
+ # When running as a PyInstaller bundle we want a stable location
|
|
|
|
|
+ # for runtime-writable files. For onefile mode PyInstaller
|
|
|
|
|
+ # extracts into a temporary folder and sets `sys.executable` to
|
|
|
|
|
+ # the extracted binary path. However `sys.argv[0]` normally
|
|
|
|
|
+ # contains the original path to the launched EXE (the file in
|
|
|
|
|
+ # the dist folder). Prefer using sys.argv[0] when available so
|
|
|
|
|
+ # writes go next to the original executable (e.g. dist\main.exe)
|
|
|
|
|
+ # rather than into the ephemeral temp extraction directory.
|
|
|
|
|
+ try:
|
|
|
|
|
+ return Path(sys.argv[0]).resolve().parent
|
|
|
|
|
+ except Exception:
|
|
|
|
|
+ return Path(sys.executable).resolve().parent
|
|
|
except Exception:
|
|
except Exception:
|
|
|
pass
|
|
pass
|
|
|
|
|
|