forked from ECP-VeloC/VELOC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auto-install.py
executable file
·124 lines (113 loc) · 5.7 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
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env python3
import sys, os.path, shutil, subprocess
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, pkg_options = ["-DENABLE_TESTS=OFF"]):
name = os.path.basename(git_link).split('.')[0]
print("Installing {0}...".format(name))
try:
tmp_dir = args.temp + '/' + name
subprocess.call(["git", "clone", "-b", dep_vers, "--depth", "1", git_link, tmp_dir])
cmake_args = ["-DCMAKE_INSTALL_PREFIX=" + args.prefix, "-DCMAKE_BUILD_TYPE=" + cmake_build_type] + compiler_options + pkg_options
subprocess.check_call(["cmake"] + cmake_args, cwd=tmp_dir)
subprocess.check_call(["cmake", "--build", tmp_dir, '--target', 'install'])
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('--protocol', default='socket_queue',
help='communication protocol between client and active backend (default: socket_queue). Only for advanced users.')
parser.add_argument('--posix-io', default='direct',
help='POSIX transfer method between scratch and persistent (default: direct, alternative: rw).')
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)')
parser.add_argument('prefix',
help='installation path prefix (typically a home directory)')
parser.add_argument('extra_cmake_args', nargs='*',
help='additional cmake arguments to pass to configure')
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)
if os.path.isdir(args.temp):
print("Installation temporary directory {0} already exists, please remove and/or specify a different one!".format(args.temp))
sys.exit(2)
try:
os.mkdir(args.temp)
except OSError as err:
print("Cannot create temporary directory {0}!".format(args.temp))
sys.exit(3)
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)
# Other depenencies
if (not args.without_deps):
install_dep('https://github.com/ECP-VeloC/KVTree.git', 'v1.2.0')
install_dep('https://github.com/ECP-VeloC/AXL.git', 'v0.5.0')
install_dep('https://github.com/ECP-VeloC/rankstr.git', 'v0.1.0')
install_dep('https://github.com/ECP-VeloC/shuffile.git', 'v0.1.0')
install_dep('https://github.com/ECP-VeloC/redset.git', 'v0.1.0')
install_dep('https://github.com/ECP-VeloC/er.git', 'v0.1.0')
# 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)
# Construct the fulls et of CMake arguments
cmake_args= ['-DCMAKE_INSTALL_PREFIX='+args.prefix,
'-DCMAKE_BUILD_TYPE='+cmake_build_type,
'-DCOMM_QUEUE='+args.protocol,
'-DPOSIX_IO='+args.posix_io] + compiler_options + args.extra_cmake_args
# Configure
print("CMake arguments: " + " ".join(cmake_args))
ret = subprocess.call(['cmake'] + cmake_args + [os.getcwd()], cwd=veloc_build,)
# Build and install
if ret == 0:
ret = subprocess.call(['cmake', '--build', veloc_build, '--target', 'install'])
# 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(4)
if ret == 0:
print("Installation successful!")
else:
print("Installation failed!")
sys.exit(ret)