-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.py
52 lines (39 loc) · 1.46 KB
/
install.py
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
import os
import subprocess
import venv
def run_command(command, env=None):
result = subprocess.run(
command,
shell=True,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=env,
)
return result.stdout.decode().strip()
def create_virtualenv(env_path):
"""Create a virtual environment at the specified path."""
venv.EnvBuilder(with_pip=True).create(env_path)
def install_requirements(env_path, requirements_file):
"""Install requirements from the requirements file into the virtual environment."""
pip_path = os.path.join(env_path, "Scripts", "pip")
run_command(f"{pip_path} install -r {requirements_file}")
def main():
env_path = ".brski_env"
# Check if virtual environment already exists
if not os.path.exists(env_path):
print(f"Creating virtual environment at {env_path}...")
create_virtualenv(env_path)
else:
print(f"Virtual environment {env_path} already exists.")
# Check for requirements.txt and install dependencies
if os.path.exists("requirements.txt"):
print("Installing requirements...")
install_requirements(env_path, "requirements.txt")
else:
print("requirements.txt not found.")
print(
"Setup complete. Virtual environment '.brski_env' is ready and dependencies are installed. Run start_env.bat to activate the environment in the command prompt."
)
if __name__ == "__main__":
main()