-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathwct-make-dev
More file actions
executable file
·200 lines (160 loc) · 5.06 KB
/
wct-make-dev
File metadata and controls
executable file
·200 lines (160 loc) · 5.06 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
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
#!/bin/bash
target=""
spec=""
tag=""
spack=""
data=""
usage () {
cat <<EOF
usage:
wct-make-dev [options] [/path/to/area]
Make a new wire-cell-toolkit and wire-cell-python development area.
This populates the current working directory or /path/to/area if given with a
trio of sub directries:
<target>/local/ - a Spack view
<target>/toolkit/ - wire-cell-toolkit source area
<target>/python/ - wire-cell-python source area
In addition a direnv file <target>/.envrc is created.
Options:
-s|--spec <spack-spec>
Specify a Spack spec as a string like /urqwjcm. If not specified, and
attempt will be made to auto detect. To find an available <spec>:
spack find -vl wire-cell-toolkit
-t|--tag <tag>
Check out given tag or branch of wire-cell-toolkit instead of master.
-S|--spack /path/to/spack
Specify the spack executable
-d|--data /path/to/wire-cell-data
Specify the directory holding contents of wire-cell-data repo. If none is
found, an attempt to clone it is made.
/path/to/area
Make and install to given directory. If not given but -t <tag> is given
then a directory of the same name in the current working directory is
used. If neither is given, the current working directory is used. The
target directory must be free of the trio of subdirectories and the .envrc
file.
EOF
exit 1
}
while [[ $# -gt 0 ]] ; do
case "$1" in
-h|--help|help) usage ;;
-s|--spec) spec="$2" ; shift 2;;
-t|--tag) tag="$2" ; shift 2;;
-S|--spack) spack="$2"; shift 2;;
-d|--data) data="$2"; shift 2;;
*) target="$1"; shift;;
esac
done
if [ -z "$target" ] ; then
target="$(pwd)"
if [ -n "$tag" ] ; then
target="$target/$tag"
fi
fi
tdir="$(realpath "$target")"
for maybe in local toolkit python
do
if [ -d "$tdir/$maybe" ] ; then
echo "$tdir/$maybe exists"
usage
fi
done
for maybe in .envrc
do
if [ -f "$tdir/$maybe" ] ; then
echo "$tdir/$maybe exists"
usage
fi
done
for maybe in "$spack" spack /srv/spack/local/bin/spack
do
maybe="$(which "$maybe")"
if [ -z "$maybe" ] ; then continue ; fi
spack="$maybe"
break;
done
if [ ! -x "$spack" ] ; then
echo "No spack found"
usage
fi
for maybe in "$data" $HOME/opt/wire-cell-data /srv/wire-cell-data
do
if [ -z "$maybe" ] ; then
continue;
fi
maybe="$(realpath "$maybe")"
if [ -f "$maybe/pdsp-wires.json.bz2" ] ; then
ddir="$maybe"
break
fi
done
if [ -z "$ddir" ] ; then
ddir="$tdir/data"
fi
if [ ! -d "$ddir" ] ; then
mkdir -p "$(dirname "$ddir")"
git clone "git@github.com:wirecell/wire-cell-data.git" "$ddir"
fi
if [ -z "$spec" ] ; then
spec=$( $spack find -l -v wire-cell-toolkit|tail -1 | awk '{print $1}' )
if [ "$spec" = "==>" ] ; then
echo "Failed to find WCT in spack, try:"
echo " spack install wire-cell-toolkit"
echo "See https://github.com/wirecell/wire-cell-spack"
usage
fi
spec="/$spec"
echo "Found spec: $spec"
fi
mkdir -p "$tdir"
cd "$tdir" || exit 1
"$spack" view add -i local "$spec"
# We do this to get around a little awkwardness. We want a view with all
# dependencies for WCT but we do not want WCT build products themselves as they
# can confuse when we subsequently build different products in our development
# area. Until a better solution, simplest thing is to simply remove the WCT
# bits that spack placed in the view.
rm -rf local/include/WireCell* local/lib/libWireCell* \
local/bin/wcsonnet local/bin/wire-cell local/bin/wcwires
if [ -d python ] ; then
echo "wire-cell-python is already cloned"
else
git clone git@github.com:wirecell/wire-cell-python.git python
fi
if [ -n "$tag" ] ; then
gitextra="--branch $tag"
fi
if [ -d toolkit ] ; then
echo "wire-cell-toolkit is already cloned"
else
git clone $gitextra git@github.com:wirecell/wire-cell-toolkit.git toolkit
fi
cat <<EOF > .envrc
load_prefix local
PKG_CONFIG_PATH="\$PKG_CONFIG_PATH:\$PWD/local/share/pkgconfig"
export WIRECELL_PREFIX=\$PWD/local
export WIRECELL_CONFIG="cd \$PWD/toolkit &&
./wcb configure \
--prefix=\$WIRECELL_PREFIX \
--with-jsonnet=\$WIRECELL_PREFIX \
--with-jsonnet-libs=gojsonnet \
--with-eigen-include=\$WIRECELL_PREFIX/include/eigen3 \
--boost-mt --boost-libs=\$WIRECELL_PREFIX/lib --boost-include=\$WIRECELL_PREFIX/include &&
cd -"
export WIRECELL_BUILD="cd \$PWD/toolkit && ./wcb install --notests && cd -"
path_add WIRECELL_PATH \$PWD/toolkit/cfg
path_add WIRECELL_PATH $ddir
layout python3
export BATS_LIB_PATH=\$PWD/toolkit/test
PATH_add \$PWD/toolkit/test/bats/bin
# to avoid having to "waf install" in order to find plugins:
path_add LD_LIBRARY_PATH $PWD/toolkit/build/{apps,aux,cuda,gen,iface,img,pgraph,sig,sigproc,sio,tbb,util}
# but note: some tests will fail without a "waf install"..
EOF
echo "### you now run ###"
echo
echo "cd $tdir && direnv allow"
echo "cd python && pip install -e . && cd -"
echo "bash -c \"\$WIRECELL_CONFIG\" && bash -c \"\$WIRECELL_BUILD\""
echo