This repository has been archived by the owner on Feb 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.py
64 lines (51 loc) · 1.41 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
53
54
55
56
57
58
59
60
61
62
63
64
"""
Installations for the necessary packages.
"""
import os
from dataclasses import dataclass
from rich.progress import track
from rysk_client.src.utils import get_logger
logger = get_logger()
@dataclass
class HostDependency:
"""
represents a host dependency
"""
name: str
install_cmd: str
def is_present(self) -> bool:
"""
silently check if the dependency is present on the host
"""
return os.popen(f"which {self.name}").read() != ""
def install(self) -> None:
"""
install the dependency
"""
os.system(self.install_cmd)
def install_dependencies() -> None:
"""
install the dependencies
"""
dependencies = [
(
"rustc",
"curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh",
),
(
"anvil",
"git clone https://github.com/foundry-rs/foundry && "
+ "cd foundry && "
+ "cargo install --path ./anvil --bins --locked --force && "
+ "rm -rf ../foundry",
),
]
logger.info(f"Installing {len(dependencies)} dependencies")
for dependency in track(dependencies):
dep = HostDependency(*dependency)
if not dep.is_present():
logger.info(f"Installing {dep.name}")
# dep.install()
logger.info("Done!")
if __name__ == "__main__":
install_dependencies()