37 lines
922 B
Python
37 lines
922 B
Python
"""Locate bundled resources in source and PyInstaller builds."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def project_root() -> Path:
|
|
frozen_root = getattr(sys, "_MEIPASS", None)
|
|
if frozen_root:
|
|
return Path(frozen_root)
|
|
return Path(__file__).resolve().parents[2]
|
|
|
|
|
|
def resource_path(*parts: str) -> Path:
|
|
return project_root().joinpath("resources", *parts)
|
|
|
|
|
|
def app_icon_path() -> Path:
|
|
return resource_path("branding", "app-icon.png")
|
|
|
|
|
|
def brand_lockup_path() -> Path:
|
|
return resource_path("branding", "brand-lockup.png")
|
|
|
|
|
|
def video_dist_path() -> Path:
|
|
candidates = (
|
|
project_root() / "video_companion" / "dist" / "index.html",
|
|
project_root() / "video_companion_dist" / "index.html",
|
|
)
|
|
for candidate in candidates:
|
|
if candidate.exists():
|
|
return candidate
|
|
return resource_path("video", "index.html")
|