-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev_setup.py
More file actions
33 lines (26 loc) · 1.24 KB
/
dev_setup.py
File metadata and controls
33 lines (26 loc) · 1.24 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
import subprocess
import sys
import os
def create_virtualenv(env_name='.python312'):
"""Create a virtual environment in the specified directory."""
if sys.version_info < (3, 3):
raise RuntimeError("Python 3.3 or later is required")
if not os.path.exists(env_name):
os.makedirs(env_name, exist_ok=True)
subprocess.check_call([sys.executable, '-m', 'venv', env_name])
def install_requirements(env_name='.python312', requirements='requirements.txt'):
"""Install the requirements from the specified requirements file."""
if not os.path.isfile(requirements):
raise FileNotFoundError(f"Could not find {requirements}")
if os.name == 'nt':
python_bin = os.path.join(env_name, 'Scripts', 'python')
else:
python_bin = os.path.join(env_name, 'bin', 'python')
subprocess.check_call([python_bin, '-m', 'pip', 'install', '--upgrade', 'pip'])
subprocess.check_call([python_bin, '-m', 'pip', 'install', '-r', requirements])
if __name__ == '__main__':
env_name = '.python312'
requirements_file = 'requirements.txt'
create_virtualenv(env_name)
install_requirements(env_name, requirements_file)
print(f"Virtual environment '{env_name}' created and dependencies installed.")