forked from ECP-VeloC/VELOC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto-install.py
executable file
·113 lines (101 loc) · 5.19 KB
/
auto-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
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
#!/usr/bin/python3
import sys, os.path, shutil
import argparse
import wget, bs4, urllib
import re
import tarfile
# CRAY-specific compiler options
# compiler_options = "-DCMAKE_C_COMPILER=cc -DCMAKE_C_FLAGS=-dynamic -DCMAKE_CXX_COMPILER=CC -DCMAKE_CXX_FLAGS=-dynamic"
compiler_options = ""
cmake_build_type="Release"
def install_dep(git_link, dep_vers):
name = os.path.basename(git_link).split('.')[0]
print("Installing {0}...".format(name))
try:
os.system("git clone -b '{0}' --depth 1 {1} {2}".format(dep_vers, git_link, args.temp + '/' + name))
os.system("cd {0} && cmake -DCMAKE_INSTALL_PREFIX={1} -DCMAKE_BUILD_TYPE={2} {3}\
&& make install".format(args.temp + '/' + name, args.prefix, cmake_build_type, compiler_options))
except Exception as err:
print("Error installing dependency {0}: {1}!".format(git_link, err))
sys.exit(4)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='VeloC installation script')
parser.add_argument('prefix',
help='installation path prefix (typically a home directory)')
parser.add_argument('--protocol', default='ipc_queue',
help='communication protocol between client and active backend (default: ipc_queue). Only for advanced users.')
parser.add_argument('--with-pdsh', action='store_true',
help='add PDSH to installation (optional)')
parser.add_argument('--without-boost', action='store_true',
help='use existing Boost libraries for ipc_queue protocol (assume pre-installed)')
parser.add_argument('--without-deps', action='store_true',
help='use existing component libraries (assume pre-installed)')
parser.add_argument('--debug', action='store_true',
help='build debug and keep temp directory')
parser.add_argument('--temp', default='/tmp/veloc',
help='temporary directory used during the install (default: /tmp/veloc)')
args = parser.parse_args()
args.prefix = os.path.abspath(args.prefix)
if not os.path.isdir(args.prefix):
print("Installation prefix {0} is not a valid directory!".format(args.prefix))
sys.exit(1)
print("Installing VeloC in {0}...".format(args.prefix))
if (args.debug):
cmake_build_type="Debug"
# Boost
if (args.protocol == "ipc_queue" and not args.without_boost):
print("Downloading Boost...")
try:
req = urllib.request.Request('https://www.boost.org/users/download', headers={'User-Agent': 'Mozilla/5.0'})
soup = bs4.BeautifulSoup(urllib.request.urlopen(req), 'html.parser')
link_list = soup.findAll('a', attrs={'href': re.compile("bz2")})
if len(link_list) > 0:
boost_arch = wget.download(link_list[0].get('href'), out=args.temp)
f = tarfile.open(boost_arch, mode='r:bz2')
f.extractall(path=args.temp)
f.close()
shutil.move(args.temp + '/' + os.path.basename(boost_arch).split('.')[0]
+ '/boost', args.prefix + '/include/boost')
except Exception as err:
print("Error installing Boost: {0}! Try to install it manually and use --without-boost. Alternatively, use --protocol=socket_queue".format(err))
sys.exit(3)
# PDSH
if (args.with_pdsh):
print("Installing PDSH...")
pdsh_tarball = wget.download('https://github.com/chaos/pdsh/releases/download/pdsh-2.33/pdsh-2.33.tar.gz', out=args.temp)
f = tarfile.open(pdsh_tarball, mode='r:gz')
f.extractall(path=args.temp)
f.close()
os.system("cd {0} && ./configure --prefix={1} --with-mrsh --with-rsh --with-ssh \
&& make install".format(args.temp + '/pdsh-2.33', args.prefix))
# Other depenencies
if (not args.without_deps):
install_dep('https://github.com/ECP-VeloC/KVTree.git', 'v1.0.3')
install_dep('https://github.com/ECP-VeloC/AXL.git', 'v0.3.0')
install_dep('https://github.com/ECP-VeloC/rankstr.git', 'v0.0.2')
install_dep('https://github.com/ECP-VeloC/shuffile.git', 'v0.0.3')
install_dep('https://github.com/ECP-VeloC/redset.git', 'v0.0.4')
install_dep('https://github.com/ECP-VeloC/er.git', 'v0.0.3')
# VeloC
veloc_build = './build'
try:
if (os.path.isdir(veloc_build)):
shutil.rmtree(veloc_build)
os.mkdir(veloc_build)
except OSError as err:
print("Cannot create build directory {0}!".format(veloc_build))
sys.exit(2)
ret = os.WEXITSTATUS(os.system("cd {0} && cmake -DCMAKE_INSTALL_PREFIX={1} -DCMAKE_BUILD_TYPE={2} -DCOMM_QUEUE={3} {4} {5}\
&& make install".format(veloc_build, args.prefix, cmake_build_type, args.protocol, compiler_options, os.getcwd())))
# Cleanup
if (not args.debug):
try:
shutil.rmtree(args.temp)
except OSError as err:
print("Cannot cleanup temporary directory {0}!".format(args.temp))
sys.exit(5)
if ret == 0:
print("Installation successful!")
else:
print("Installation failed!")
sys.exit(ret)