-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_thirdparty.py
51 lines (40 loc) · 1.48 KB
/
install_thirdparty.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 argparse
import subprocess
import glob
import re
import os
parser = argparse.ArgumentParser(description='Installing ThirdParty')
parser.add_argument('--all', help='install all dependencies', default=True)
parser.add_argument('--reinstall_all',
help='re-install all dependencies', default=False)
parser.add_argument(
'--reinstall', help='reinstall one library', type=str, default="")
def install_all_deps():
subprocess.call("./thirdparty/rules/cmake.sh")
for rule in glob.glob("./thirdparty/rules/*.sh"):
subprocess.call("./" + rule, shell=True)
def reinstall_all_deps():
to_remove = str("./thirdparty/all/")
if os.path.exists(to_remove):
subprocess.call(str("rm -r " + to_remove), shell=True)
install_all_deps()
def reinstall_one_lib(lib):
all_rules = glob.glob("./thirdparty/rules/*.sh")
names = []
for rule in all_rules:
names.append(re.search('%s(.*)%s' %
('./thirdparty/rules/', '.sh'), rule).group(1))
if lib not in names:
print('Error no rules found for ' + lib)
else:
to_remove = str("./thirdparty/all/" + lib)
if os.path.exists(to_remove):
subprocess.call(str("rm -r " + to_remove), shell=True)
subprocess.call("./thirdparty/rules/" + lib + ".sh", shell=True)
args = parser.parse_args()
if args.reinstall != "":
reinstall_one_lib(args.reinstall)
elif args.reinstall_all:
reinstall_all_deps()
else:
install_all_deps()