-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathinstall-local.sh
executable file
·218 lines (187 loc) · 5.88 KB
/
install-local.sh
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/usr/bin/env bash
usage() {
cat <<'_end_'
Usage: install-local.sh [--pyvenv=VENVOPT] [--env=SCRIPT] [--prefix=PATH] TARGET [TARGET...]
Setup NSuite framework, build and install simulators, benchmarks,
and validation tests.
Options:
--pyvenv=VENVOPT Customize use of Python virtual environment (see below)
--env=SCRIPT Source SCRIPT before building.
--prefix=PATH Use PATH as base for install and other run-time
working directories.
TARGET is one of:
arbor Build Arbor.
neuron Build NEURON.
coreneuron Build CoreNEURON.
all Build all simulators.
Building a TARGET will also build any associated tests and
benchmarks as required.
By default, a Python virtual environment is created in which required modules
are installed if they are missing in the system environment.
VENVOPT is one of:
disable Do not use a Python virtualenv at all.
inherit Use a virtualenv, using site packages.
enable Use a virtualenv, ignoring site packages (default).
_end_
}
# Determine NSuite root and default ns_prefix.
unset CDPATH
ns_base_path=$(cd "${BASH_SOURCE[0]%/*}"; pwd)
ns_prefix=${NS_PREFIX:-$(pwd)}
# Parse arguments.
ns_build_arbor=false
ns_build_nest=false
ns_build_neuron=false
ns_build_coreneuron=false
ns_environment=
ns_pyvenv=enable
while [ "$1" != "" ]
do
case $1 in
arbor )
ns_build_arbor=true
;;
neuron )
ns_build_neuron=true
;;
coreneuron )
ns_build_coreneuron=true
;;
all )
ns_build_arbor=true
ns_build_neuron=true
ns_build_coreneuron=true
;;
--pyvenv=* )
ns_pyvenv=${1#--pyvenv=}
;;
--pyvenv )
shift
ns_pyvenv=$1
;;
--env=* )
ns_environment=${1#--env=}
;;
--env )
shift
ns_environment=$1
;;
--prefix=* )
ns_prefix=${1#--prefix=}
;;
--prefix )
shift
ns_prefix=$1
;;
* )
echo "unknown option '$1'"
usage
exit 1
esac
shift
done
if [ "$ns_pyvenv" != disable -a "$ns_pyvenv" != enable -a "$ns_pyvenv" != inherit ]; then
echo "unrecognized argument for --pyvenv: '$ns_pyvenv'"
usage
exit 1
fi
# Load utility functions and set up default environment.
source "$ns_base_path/scripts/util.sh"
mkdir -p "$ns_prefix"
ns_prefix=$(full_path "$ns_prefix")
source "$ns_base_path/scripts/environment.sh"
default_environment
# Run a user supplied configuration script if it was provided with the -e flag.
# This will make changes to the configuration variables ns_* set in environment()
if [ "$ns_environment" != "" ]; then
msg "using additional configuration: $ns_environment"
if [ ! -f "$ns_environment" ]; then
err "file '$ns_environment' not found"
exit 1
fi
source "$ns_environment"
echo
fi
msghi "---- TARGETS ----"
msg "build arbor: $ns_build_arbor"
msg "build neuron: $ns_build_neuron"
msg "build coreneuron: $ns_build_coreneuron"
msg "build validation: $ns_validate"
echo
msghi "---- PATHS ----"
msg "nsuite root: $ns_base_path"
msg "work dir prefix: $ns_prefix"
msg "install path: $ns_install_path"
msg "build path: $ns_build_path"
msg "input path: $ns_input_path"
msg "output path: $ns_output_path"
echo
msghi "---- SYSTEM ----"
msg "system: $ns_system"
msg "using mpi: $ns_with_mpi"
msg "C compiler: $ns_cc"
msg "C++ compiler: $ns_cxx"
msg "python: $ns_python"
echo
msghi "---- ARBOR ----"
msg "repo: $ns_arb_git_repo"
msg "branch: $ns_arb_branch"
msg "arch: $ns_arb_arch"
msg "gpu: $ns_arb_gpu"
msg "vectorize: $ns_arb_vectorize"
echo
msghi "---- NEURON ----"
msg "tarball: $ns_nrn_tarball"
msg "url: $ns_nrn_url"
msg "repo: $ns_nrn_git_repo"
msg "branch: $ns_nrn_branch"
echo
msghi "---- CoreNEURON ----"
msg "repo: $ns_cnrn_git_repo"
msg "sha: $ns_cnrn_sha"
mkdir -p "$ns_build_path"
# Record system configuration name, timestamp.
# (This data will also be recorded in constructed environments.)
# Note: format (and sed processing) chosen to match RFC 3339 profile
# for ISO 8601 date formatting, matching GNU date -Isec output.
ns_timestamp=$(date +%Y-%m-%ST%H:%M:%S%z | sed 's/[0-9][0-9]$/:&/')
echo "$ns_timestamp" > "$ns_build_path/timestamp"
echo "${ns_sysname:=$(hostname -s)}" > "$ns_build_path/sysname"
# Set up python virtual environment.
if [ "$ns_pyvenv" != disable ]; then
echo
msghi "Initializing python virtual environment"
ns_pyvenv_opt=
if [ "$ns_pyvenv" == inherit ]; then
ns_pyvenv_opt=--system-site-packages
fi
msg "Installing python modules: $ns_pyvenv_modules"
(
exec >> "$ns_build_path/log_pyvenv" 2>&1
if "$ns_python" -m venv $ns_pyvenv_opt "$ns_pyvenv_path"; then
source "$ns_pyvenv_path/bin/activate"
for pkg in $ns_pyvenv_modules; do
pip install "$pkg"
done
fi
)
fi
# Build simulator targets.
export CC="$ns_cc"
export CXX="$ns_cxx"
[ "$ns_build_arbor" = true ] && echo && source "$ns_base_path/scripts/build_arbor.sh"
cd "$ns_base_path"
[ "$ns_build_neuron" = true ] && echo && source "$ns_base_path/scripts/build_neuron.sh"
cd "$ns_base_path"
[ "$ns_build_coreneuron" = true ] && echo && source "$ns_base_path/scripts/build_coreneuron.sh"
cd "$ns_base_path"
# attempt to build validation models/generators.
if [ "$ns_validate" != disable ]; then
echo
msghi "Building validation tests and generators"
source "$ns_base_path/scripts/build_validation_models.sh"
cd "$ns_base_path"
fi
echo
msghi "Installation finished"
echo