33 lines
759 B
Python
33 lines
759 B
Python
#!/usr/bin/env python3
|
|
"""Compatibility launcher for the Web GUI launcher window."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import runpy
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT_DIR = Path(__file__).resolve().parent
|
|
TARGET = ROOT_DIR / "gui" / "webgui_launcher.py"
|
|
VENV_PYTHON = ROOT_DIR / ".venv" / "Scripts" / "python.exe"
|
|
|
|
|
|
def _reexec_with_venv() -> None:
|
|
if not VENV_PYTHON.exists():
|
|
return
|
|
if Path(sys.executable).resolve() == VENV_PYTHON.resolve():
|
|
return
|
|
os.execv(str(VENV_PYTHON), [str(VENV_PYTHON), str(TARGET), *sys.argv[1:]])
|
|
|
|
|
|
def main() -> None:
|
|
_reexec_with_venv()
|
|
sys.argv = [str(TARGET), *sys.argv[1:]]
|
|
runpy.run_path(str(TARGET), run_name="__main__")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|