Spaces:
Sleeping
Sleeping
File size: 1,134 Bytes
6127e00 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | from __future__ import annotations
import sys
from pathlib import Path
def resolve_app_root() -> Path:
if getattr(sys, "frozen", False):
return Path(sys.executable).resolve().parent
return Path(__file__).resolve().parents[2]
def resolve_bundle_root() -> Path:
meipass = getattr(sys, "_MEIPASS", None)
if meipass:
return Path(str(meipass)).resolve()
if getattr(sys, "frozen", False):
return Path(sys.executable).resolve().parent
return resolve_app_root()
def resolve_frontend_dist_dir() -> Path:
base = resolve_bundle_root() if getattr(sys, "frozen", False) else resolve_app_root()
return base / "frontend" / "dist"
def resolve_core_path(*parts: str) -> Path:
if getattr(sys, "frozen", False):
return resolve_bundle_root().joinpath("app", "core", *parts)
return resolve_app_root().joinpath("backend", "app", "core", *parts)
def resolve_local_data_path(*parts: str) -> Path:
if getattr(sys, "frozen", False):
return resolve_bundle_root().joinpath("local_data", *parts)
return resolve_app_root().joinpath("backend", "local_data", *parts)
|