-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstalldeps_cmssw.sh
70 lines (60 loc) · 2.31 KB
/
installdeps_cmssw.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
# no shebang, must be sourced
## based on SÃbastien Brochet's install-tensorflow.sh script in cp3-llbb/HHTools)
## deduce source location from the script name
if [[ -z "${ZSH_NAME}" ]]; then
thisscript="$(readlink -f ${BASH_SOURCE})"
else
thisscript="$(readlink -f ${0})"
fi
pipinstall="$(dirname ${thisscript})/.python"
# Check if in CMSSW
if [ -z "$CMSSW_BASE" ]; then
echo "You must use this package inside a CMSSW environment"
return 1
fi
pymajmin=$(python -c 'import sys; print(".".join(str(num) for num in sys.version_info[:2]))')
if [[ "${pymajmin}" != "2.7" ]]; then
echo "--> Only python 2.7 is supported"
return 1
fi
# Check if it is already installed
scram tool info samadhidep > /dev/null 2> /dev/null
if [ $? -eq 0 ]; then
echo "--> already installed (according to scram)"
return 0
fi
# First, download and install pip, if needed
bk_pythonpath="${PYTHONPATH}"
python -m pip --version > /dev/null 2> /dev/null
if [ $? -ne 0 ]; then
echo "--> No pip found, bootstrapping in ${pipinstall}"
[ -d "${pipinstall}" ] || mkdir "${pipinstall}"
if [ ! -f "${pipinstall}/bin/pip" ]; then
wget -O "${pipinstall}/get-pip.py" "https://bootstrap.pypa.io/get-pip.py"
python "${pipinstall}/get-pip.py" --prefix="${pipinstall}" --no-setuptools
fi
export PYTHONPATH="${pipinstall}/lib/python${pymajmin}/site-packages:${PYTHONPATH}"
fi
## install dependencies
installpath="${CMSSW_BASE}/install/samadhidep"
echo "--> Installing MySQL-python and storm"
python -m pip install --prefix="${installpath}" --ignore-installed --upgrade --upgrade-strategy=only-if-needed MySQL-python storm
# root_interface toolfile
toolfile="${installpath}/samadhidep.xml"
cat <<EOF_TOOLFILE >"${toolfile}"
<tool name="samadhidep" version="1.2.0">
<info url="https://github.com/cp3-llbb/SAMADhi"/>
<client>
<environment name="SAMADHIDEP_BASE" default="${installpath}"/>
<runtime name="LD_LIBRARY_PATH" value="\$SAMADHIDEP_BASE/lib" type="path"/>
<runtime name="PYTHONPATH" value="\$SAMADHIDEP_BASE/lib/python${pymajmin}/site-packages" type="path"/>
</client>
</tool>
EOF_TOOLFILE
## cleanup
rm -rf "${pipinstall}"
export PYTHONPATH="${bk_pythonpath}"
echo "--> Updating environment"
scram setup "${toolfile}"
cmsenv
echo "--> SAMADhi dependencies are installed. The package can normally be installed with 'scram b' now"