34 lines
777 B
Python
34 lines
777 B
Python
#!/usr/bin/env python3
|
|
"""Compatibility launcher for the desktop GUI."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import runpy
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from douyin.core import path_config
|
|
|
|
ROOT_DIR = Path(__file__).resolve().parent.parent
|
|
TARGET = ROOT_DIR / "gui" / "gui_app.py"
|
|
VENV_PYTHON = Path(path_config.get_venv_python_path())
|
|
|
|
|
|
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()
|