-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.py
executable file
·51 lines (41 loc) · 1.66 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
import platform
import sys
from subprocess import run, CalledProcessError
USER_PLATFORM = platform.system().lower()
def run_install():
if 'darwin' in USER_PLATFORM:
return install_macOS()
elif 'linux' in USER_PLATFORM:
return install_linux()
else:
raise RuntimeError('Unsupported Platform.')
def install_macOS():
tarball_name = "smoldyn-2.72-mac.tgz"
tar_dir = tarball_name.replace('.tgz', '')
try:
run("poetry env use python3.10".split(), check=True)
run("poetry run pip install --upgrade pip".split(), check=True)
run("poetry lock --no-update".split(), check=True)
run("poetry install -v".split(), check=True)
run("poetry run pip uninstall smoldyn".split(), check=True)
run("wget https://www.smoldyn.org/smoldyn-2.72-mac.tgz".split(), check=True)
run(f"tar -xzvf {tarball_name}".split(), check=True)
run(f"rm {tarball_name}".split(), check=True)
run(f"sudo -H {tar_dir}/install.sh".split(), check=True)
run("cd ..".split(), check=True)
except CalledProcessError as e:
print(f'An error occured: {e}')
print('Exiting')
sys.exit(1)
def install_linux():
try:
run("poetry env use python3.10".split(), check=True)
run("echo 'smoldyn' >> requirements.txt".split(), check=True)
run("poetry run pip install -r requirements.txt".split(), check=True)
run("poetry lock --no-update".split(), check=True)
run("poetry install -v".split(), check=True)
except CalledProcessError as e:
print(f'An error occured: {e}. Exiting')
sys.exit(1)
if __name__ == '__main__':
run_install()