-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall_smact.py
More file actions
75 lines (58 loc) · 2.1 KB
/
Copy pathinstall_smact.py
File metadata and controls
75 lines (58 loc) · 2.1 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import os
import subprocess
import sys
def check_python_version():
"""
Check if the Python version meets the minimum requirement.
Raises:
SystemError: If Python version is less than 3.9
"""
if sys.version_info < (3, 9):
raise SystemError("Python 3.9 or higher is required")
def create_virtual_environment():
"""
Create a new virtual environment named 'smact-env' if it doesn't exist.
The virtual environment is created using the venv module in the current directory.
"""
if not os.path.exists("smact-env"):
subprocess.run([sys.executable, "-m", "venv", "smact-env"])
print("Created virtual environment: smact-env")
def install_requirements():
"""
Install required packages from requirements.txt.
Uses pip on Windows and pip3 on other operating systems.
"""
pip_cmd = "pip" if os.name == "nt" else "pip3"
subprocess.run([pip_cmd, "install", "-r", "requirements.txt"])
print("Installed requirements")
def setup_smact():
"""
Set up SMACT by cloning the repository and installing in development mode.
1. Clones the SMACT repository if not present
2. Changes to SMACT directory
3. Installs SMACT in development mode
4. Returns to original directory
"""
# Clone SMACT repository if not present
if not os.path.exists("SMACT"):
subprocess.run(["git", "clone", "https://github.com/WMD-group/SMACT.git"])
print("Cloned SMACT repository")
# Install SMACT in development mode
os.chdir("SMACT")
subprocess.run([sys.executable, "setup.py", "develop"])
os.chdir("..")
print("Installed SMACT in development mode")
def main():
"""Main function to orchestrate the SMACT setup process."""
print("Setting up SMACT environment...")
check_python_version()
create_virtual_environment()
install_requirements()
setup_smact()
print("\nSetup complete! You can now activate the environment:")
if os.name == "nt":
print(" smact-env\\Scripts\\activate")
else:
print(" source smact-env/bin/activate")
if __name__ == "__main__":
main()