-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
56 lines (47 loc) · 1.94 KB
/
Copy pathsetup.py
File metadata and controls
56 lines (47 loc) · 1.94 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
47
48
49
50
51
52
53
54
55
56
import subprocess
import sys
import os
from pathlib import Path
def setup_venv():
"""Set up the virtual environment and install dependencies"""
venv_path = Path('.venv')
try:
# Create virtual environment
print("Se creeaza mediul virtual...")
subprocess.run([sys.executable, '-m', 'venv', '.venv'], check=True)
# Determine the pip path based on OS
if os.name == 'nt': # Windows
pip_path = venv_path / 'Scripts' / 'pip.exe'
python_path = venv_path / 'Scripts' / 'python.exe'
else: # Unix-like
pip_path = venv_path / 'bin' / 'pip'
python_path = venv_path / 'bin' / 'python'
# Upgrade pip
print("Se actualizeaza pip...")
subprocess.run([str(pip_path), 'install', '--upgrade', 'pip'], check=True)
# Install wheel for better package installation
print("Se instaleaza wheel...")
subprocess.run([str(pip_path), 'install', 'wheel'], check=True)
# Install requirements
print("Se instaleaza cerintele...")
subprocess.run([str(pip_path), 'install', '-r', 'requirements.txt'], check=True)
print("\nConfigurare completa!")
print("Pentru a activa mediul virtual:")
if os.name == 'nt':
print("Rulati: .venv\\Scripts\\activate")
else:
print("Rulati: source .venv/bin/activate")
except subprocess.CalledProcessError as e:
print(f"Eroare la configurarea mediului virtual: {e}")
print("Cod de iesire:", e.returncode)
if e.output:
print("Detalii:", e.output.decode())
sys.exit(1)
except Exception as e:
print(f"Eroare neasteptata: {e}")
sys.exit(1)
if __name__ == '__main__':
if os.name != 'nt' and os.geteuid() == 0:
print("AVERTISMENT: Nu rulati acest script ca root/administrator!")
sys.exit(1)
setup_venv()