-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpyml-launch.py
More file actions
executable file
·34 lines (26 loc) · 1.04 KB
/
Copy pathpyml-launch.py
File metadata and controls
executable file
·34 lines (26 loc) · 1.04 KB
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
#!/usr/bin/env python3
"""Run a pipeline on whichever backend `PYML_BACKEND` selects, from the checkout.
See `plugins/python/pyml_launch.py` for what the two backends spell differently.
Re-runs itself under the repo's venv when started from another interpreter: the
launcher hands its own site directories to GStreamer and to g2g, neither of
which has a venv of its own.
"""
import os
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent
VENV = ROOT / ".venv"
VENV_PYTHON = (
VENV / "Scripts" / "python.exe" if os.name == "nt" else VENV / "bin" / "python"
)
def main():
# sys.prefix, not the executable path: a venv's `python` is a symlink to the
# base interpreter, so resolving it would say we are already inside.
if VENV_PYTHON.exists() and Path(sys.prefix) != VENV:
return subprocess.call([str(VENV_PYTHON), __file__, *sys.argv[1:]])
sys.path.insert(0, str(ROOT / "plugins" / "python"))
import pyml_launch
return pyml_launch.main()
if __name__ == "__main__":
sys.exit(main())