-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
56 lines (43 loc) · 1.64 KB
/
Copy pathsetup.py
File metadata and controls
56 lines (43 loc) · 1.64 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 os
import sys
import subprocess
import platform
def run_command(command):
print(f"Executing: {command}")
try:
subprocess.check_call(command, shell=True)
except subprocess.CalledProcessError as e:
print(f"Error executing command: {e}")
sys.exit(1)
def main():
system = platform.system() # 'Darwin' (Mac) or 'Windows'
venv_dir = ".venv"
print(f"Detected System: {system}")
# 1. Create Virtual Environment if it doesn't exist
if not os.path.exists(venv_dir):
print("Creating virtual environment...")
run_command(f"{sys.executable} -m venv {venv_dir}")
# 2. Determine paths to Python and Pip based on OS
if system == "Windows":
pip_path = os.path.join(venv_dir, "Scripts", "pip")
python_path = os.path.join(venv_dir, "Scripts", "python")
req_file = "requirements-win.txt"
else: # MacOS
pip_path = os.path.join(venv_dir, "bin", "pip")
req_file = "requirements-mac.txt"
# 3. Upgrade Pip
run_command(f"{pip_path} install --upgrade pip")
# 4. Install Common Dependencies
print("Installing common dependencies...")
run_command(f"{pip_path} install -r requirements-common.txt")
# 5. Install Platform-Specific Dependencies
print(f"Installing {system}-specific dependencies from {req_file}...")
run_command(f"{pip_path} install -r {req_file}")
print("\n[OK] Setup Complete!")
print("To activate your environment, run:")
if system == "Windows":
print(f" .\\{venv_dir}\\Scripts\\activate")
else:
print(f" source {venv_dir}/bin/activate")
if __name__ == "__main__":
main()