-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
50 lines (42 loc) · 1.45 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
import os
import subprocess
import json
def create_folders():
# Create main folders if they don't exist
folders = ["temp", "config", "config/stream", "config/topo", "expSrc", "stream-replay/data", "stream-replay/logs"]
for folder in folders:
if not os.path.exists(folder):
os.mkdir(folder)
def execute_commands():
# Execute commands
subprocess.run(["cargo", "build", "--release"], cwd="stream-replay")
def pip_install():
# if pip is not installed, install it
try:
subprocess.run(["pip", "--version"])
except FileNotFoundError:
subprocess.run(["sudo", "apt", "install", "python3-pip", "-y"])
## install required packages
with open("requirements.txt") as f:
packages = f.read().splitlines()
for package in packages:
subprocess.run(["pip", "install", package])
def cargo_install():
while True:
try:
subprocess.run(["source", "$HOME/.cargo/env"])
subprocess.run(["cargo", "--version"])
break
except Exception as e:
try:
subprocess.run("curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh")
break
except Exception as e:
subprocess.run(["sudo", "apt", "install", "curl"])
def main():
create_folders()
cargo_install()
execute_commands()
pip_install()
if __name__ == "__main__":
main()