-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun.py
More file actions
executable file
·46 lines (34 loc) · 1.34 KB
/
run.py
File metadata and controls
executable file
·46 lines (34 loc) · 1.34 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
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
# Copyright (C) 2025 Collabora Limited
# Author: Denys Fedoryshchenko <denys.f@collabora.com>
# SPDX-License-Identifier: LGPL-2.1-or-later
import subprocess
import sys
import os
from config import APP_TITLE, APP_VERSION, PORT
def setup_venv():
"""Set up virtual environment if it doesn't exist"""
venv_path = ".venv"
if not os.path.exists(venv_path):
print("Creating virtual environment...")
subprocess.run([sys.executable, "-m", "venv", venv_path], check=True)
# Install requirements
pip_path = os.path.join(venv_path, "bin", "pip")
if os.name == "nt": # Windows
pip_path = os.path.join(venv_path, "Scripts", "pip.exe")
print("Installing requirements...")
subprocess.run([pip_path, "install", "-r", "requirements.txt"], check=True)
def run_app():
"""Run the application with virtual environment"""
venv_path = ".venv"
python_path = os.path.join(venv_path, "bin", "python")
if os.name == "nt": # Windows
python_path = os.path.join(venv_path, "Scripts", "python.exe")
print(f"Starting {APP_TITLE} v{APP_VERSION}...")
print(f"Open: http://staging.kernelci.org")
print("Login: admin/admin (change password on first login)")
print("")
os.execv(python_path, [python_path, "main.py"])
if __name__ == "__main__":
setup_venv()
run_app()