-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_requirements.py
More file actions
161 lines (131 loc) · 3.99 KB
/
install_requirements.py
File metadata and controls
161 lines (131 loc) · 3.99 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import subprocess
from src.messages import print_log, print_warn
def install_requirements() -> None:
"""
Installs all requirements. Outputs success if all dependencies were installed. If one or more installations
failed, outputs a warning.
"""
print_log("Installing requirements...")
successful = True
if not install_click():
successful = False
if not install_inquirer():
successful = False
if not install_numpy():
successful = False
if not install_pycurl():
successful = False
if not install_psutil():
successful = False
if not install_dateutil():
successful = False
if not install_matplotlib():
successful = False
if successful:
print_log("All dependencies installed.")
return
print_warn("Not all dependencies could be installed!")
def install_psutil() -> bool:
"""
Installs psutil to venv using pip.
:return: True for success, False otherwise
"""
print("Install psutil... ", end="", flush=True)
try:
subprocess.check_output(["bin/pip", "install", "psutil"])
except FileNotFoundError:
try:
subprocess.check_output(["bin/pip", "install", "python3-psutil"])
except FileNotFoundError:
print("failed.")
return False
print("done.")
return True
def install_dateutil() -> bool:
print("Install dateutil... ", end="", flush=True)
try:
subprocess.check_output(["bin/pip", "install", "python-dateutil"])
except FileNotFoundError:
print("failed.")
return False
print("done.")
return True
def install_matplotlib() -> bool:
print("Install matplotlib... ", end="", flush=True)
try:
subprocess.check_output(["sudo", "bin/pip", "install", "matplotlib"])
except FileNotFoundError:
print("failed.")
return False
print("done.")
return True
def install_click() -> bool:
"""
Installs click to venv using pip.
:return: True for success, False otherwise
"""
print("Install click... ", end="", flush=True)
try:
subprocess.check_output(["bin/pip", "install", "click"])
except FileNotFoundError:
try:
subprocess.check_output(["bin/pip", "install", "python3-click"])
except FileNotFoundError:
print("failed.")
return False
print("done.")
return True
def install_inquirer() -> bool:
"""
Installs inquirer to venv using pip.
:return: True for success, False otherwise
"""
print("Install inquirer... ", end="", flush=True)
try:
subprocess.check_output(["bin/pip", "install", "inquirer"])
except FileNotFoundError:
try:
subprocess.check_output(["bin/pip", "install", "python3-inquirer"])
except FileNotFoundError:
print("failed.")
return False
print("done.")
return True
def install_numpy() -> bool:
"""
Installs numpy to venv using pip.
:return: True for success, False otherwise
"""
print("Install numpy... ", end="", flush=True)
try:
subprocess.check_output(["bin/pip", "install", "numpy"])
except FileNotFoundError:
try:
subprocess.check_output(["bin/pip", "install", "python3-numpy"])
except FileNotFoundError:
print("failed.")
return False
print("done.")
return True
def install_pycurl() -> bool:
"""
Installs pycurl to venv using pip.
:return: True for success, False otherwise
"""
print("Install pycurl... ", end="", flush=True)
try:
subprocess.check_output(
["bin/pip", "install", "pycurl"],
)
except FileNotFoundError:
try:
subprocess.check_output(
["bin/pip", "install", "python3-pycurl"],
)
except FileNotFoundError:
print("failed.")
return False
print("done.")
return True
if __name__ == "__main__":
install_requirements()