-
Notifications
You must be signed in to change notification settings - Fork 324
Expand file tree
/
Copy pathinstaller.py
More file actions
44 lines (34 loc) · 1.05 KB
/
installer.py
File metadata and controls
44 lines (34 loc) · 1.05 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
"""
Dependency installation helpers (pip install -r requirements.txt).
"""
from __future__ import annotations
import subprocess
import sys
from pathlib import Path
from ui import info, warn, error
BASE_DIR = Path(__file__).resolve().parent
REQUIREMENTS_FILE = BASE_DIR / "requirements.txt"
def install_dependencies() -> None:
"""Install dependencies from requirements.txt using the current Python interpreter."""
if not REQUIREMENTS_FILE.exists():
error(f"{REQUIREMENTS_FILE.name} not found. Nothing to install.")
return
warn(
"Running pip install -r requirements.txt "
"using the current Python interpreter."
)
cmd = [
sys.executable,
"-m",
"pip",
"install",
"-r",
str(REQUIREMENTS_FILE),
]
info(f"Running: {' '.join(cmd)}")
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError as exc:
error(f"Dependency installation failed (exit code {exc.returncode}).")
return
info("Dependencies installed successfully.")