-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.sh
executable file
·162 lines (137 loc) · 4.2 KB
/
setup.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
#!/bin/bash
(
set -euo pipefail
cd $(dirname ${BASH_SOURCE[0]})
PKGDIR="$(readlink -f .)"
declare -i doPrintEnv=0
declare -i doPrintEnvInstr=0
declare -i needROOFITSYS_ROOTSYS=0
declare -a setupArgs=()
for farg in "$@"; do
fargl="$(echo $farg | awk '{print tolower($0)}')"
if [[ "$fargl" == "env" ]]; then
doPrintEnv=1
elif [[ "$fargl" == "envinstr" ]]; then
doPrintEnvInstr=1
else
setupArgs+=( "$farg" )
fi
done
declare -i nSetupArgs
nSetupArgs=${#setupArgs[@]}
if [[ -z "${CMSSW_BASE+x}" ]]; then
echo "You must have a valid CMSSW_BASE environment variable."
exit 1
fi
xgboost_cfg=${CMSSW_BASE}/config/toolbox/${SCRAM_ARCH}/tools/selected/py2-xgboost.xml
xgboost_version="$(grep -e 'tool name' ${xgboost_cfg} | grep 'py2-xgboost')"
xgboost_version="${xgboost_version##*=\"}"
xgboost_version="${xgboost_version%%\"*}"
xgboost_path="/cvmfs/cms.cern.ch/${SCRAM_ARCH}/external/py2-xgboost/${xgboost_version}/lib/python3.6/site-packages/xgboost"
printenv() {
if [[ -d ${CMSSW_BASE}/src/IvyFramework/IvyDataTools ]]; then
envopts="env standalone"
${CMSSW_BASE}/src/IvyFramework/IvyDataTools/setup.sh ${envopts}
eval $(${CMSSW_BASE}/src/IvyFramework/IvyDataTools/setup.sh ${envopts})
fi
if [[ -d ${CMSSW_BASE}/src/IvyFramework/IvyMLTools ]]; then
envopts="env xgboost_path=${xgboost_path}"
${CMSSW_BASE}/src/IvyFramework/IvyMLTools/setup.sh ${envopts}
eval $(${CMSSW_BASE}/src/IvyFramework/IvyMLTools/setup.sh ${envopts})
fi
libappend="${PKGDIR}/lib"
end=""
if [[ ! -z "${LD_LIBRARY_PATH+x}" ]]; then
end=":${LD_LIBRARY_PATH}"
fi
if [[ "${end}" != *"$libappend"* ]]; then
echo "export LD_LIBRARY_PATH=${libappend}${end}"
export LD_LIBRARY_PATH=${libappend}${end}
fi
pythonappend="${PKGDIR}/python"
end=""
if [[ ! -z "${PYTHONPATH+x}" ]]; then
end=":${PYTHONPATH}"
fi
if [[ "${end}" != *"$pythonappend"* ]]; then
echo "export PYTHONPATH=${pythonappend}${end}"
export PYTHONPATH="${pythonappend}${end}"
fi
pathappend="${PKGDIR}/executables"
end=""
if [[ ! -z "${PATH+x}" ]]; then
end=":${PATH}"
fi
if [[ "${end}" != *"$pathappend"* ]]; then
echo "export PATH=${pathappend}${end}"
export PATH=${pathappend}${end}
fi
}
doenv() {
if [[ -d ${CMSSW_BASE}/src/IvyFramework/IvyDataTools ]]; then
envopts="env standalone"
eval $(${CMSSW_BASE}/src/IvyFramework/IvyDataTools/setup.sh ${envopts})
fi
if [[ -d ${CMSSW_BASE}/src/IvyFramework/IvyMLTools ]]; then
envopts="env xgboost_path=${xgboost_path}"
eval $(${CMSSW_BASE}/src/IvyFramework/IvyMLTools/setup.sh ${envopts})
fi
pythonappend="${PKGDIR}/python"
end=""
if [[ ! -z "${PYTHONPATH+x}" ]]; then
end=":${PYTHONPATH}"
fi
if [[ "${end}" != *"$pythonappend"* ]]; then
export PYTHONPATH="${pythonappend}${end}"
fi
}
printenvinstr () {
echo
echo "to use this repo, you must run:"
echo
echo 'eval $('${BASH_SOURCE[0]}' env)'
echo "or"
echo 'eval `'${BASH_SOURCE[0]}' env`'
echo
echo "if you are using a bash-related shell, or you can do"
echo
echo ${BASH_SOURCE[0]}' env'
echo
echo "and change the commands according to your shell in order to do something equivalent to set up the environment variables."
echo
}
if [[ $doPrintEnv -eq 1 ]]; then
printenv
exit
elif [[ $doPrintEnvInstr -eq 1 ]]; then
printenvinstr
exit
fi
if [[ $nSetupArgs -eq 0 ]]; then
setupArgs+=( -j 1 )
nSetupArgs=2
fi
if [[ "$nSetupArgs" -eq 1 ]] && [[ "${setupArgs[0]}" == *"clean"* ]]; then
make clean
exit $?
elif [[ "$nSetupArgs" -ge 1 ]] && [[ "$nSetupArgs" -le 2 ]] && [[ "${setupArgs[0]}" == *"-j"* ]]; then
: ok
else
echo "Unknown arguments:"
echo " ${setupArgs[@]}"
echo "Should be nothing, env, envinstr, clean, or -j [Ncores]"
exit 1
fi
doenv
# Run IvyFramework commands
${CMSSW_BASE}/src/IvyFramework/IvyDataTools/setup.sh standalone "${setupArgs[@]}" 1> /dev/null || exit $?
${CMSSW_BASE}/src/IvyFramework/IvyMLTools/setup.sh "xgboost_path=${xgboost_path}" "${setupArgs[@]}" 1> /dev/null || exit $?
# Compile this repository
make "${setupArgs[@]}"
compile_status=$?
if [[ ${compile_status} -ne 0 ]]; then
echo "Compilation failed with status ${compile_status}."
exit ${compile_status}
fi
printenvinstr
)