-
Notifications
You must be signed in to change notification settings - Fork 21
/
setup.sh
129 lines (113 loc) · 3.64 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
#!/usr/bin/env bash
function find_os_version()
{
try_release=$(lsb_release -rs 2> /dev/null || echo 'not found')
if [ "${try_release}" != 'not found' ]
then
echo $(echo "${try_release}" | cut -f1 -d.)
return 0
fi
try_release=$(rpm -q --queryformat '%{RELEASE}' rpm 2> /dev/null || echo 'not found')
if [ "${try_release}" != 'not found' ]
then
echo $(echo "${try_release}" | grep -o [[:digit:]]*\$)
return 0
fi
try_release=$(cat /etc/redhat-release 2> /dev/null || echo 'not found')
if [ "${try_release}" != 'not found' ]
then
echo $(echo "${try_release}" | grep -o '[[:digit:]]' | head -1)
return 0
else
echo "Unable to find current OS version, aborting"
return -1
fi
}
OS_VERSION=centos7
os_ver=$(find_os_version)
if [ "${os_ver}" == "6" ]
then
OS_VERSION=slc6
fi
export OS_VERSION
#LCG_VERSION=LCG_95
#LCG_ARCH=x86_64-${OS_VERSION}-gcc8-opt
LCG_VERSION=LCG_96
LCG_ARCH=x86_64-${OS_VERSION}-gcc8-opt
export LCG_VERSION
export LCG_ARCH
PROJECT_NAME="cms-l1t-analysis"
if [ -n "${PROJECT_ROOT}" ] ; then
old_projectbase=${PROJECT_ROOT}
fi
if [ "x${BASH_ARGV[0]}" = "x" ]; then
if [ ! -f setup.sh ]; then
echo ERROR: must "cd where/${PROJECT_NAME}/is" before calling ". setup.sh" for this version of bash!
PROJECT_ROOT=; export PROJECT_ROOT
return 1
fi
PROJECT_ROOT="$PWD"; export PROJECT_ROOT
else
# get param to "."
envscript=$(dirname ${BASH_ARGV[0]})
PROJECT_ROOT=$(cd ${envscript};pwd); export PROJECT_ROOT
fi
# clean PATH and PYTHONPATH
if [ -n "${old_projectbase}" ] ; then
PATH=`python ${PROJECT_ROOT}/bin/remove_from_path.py "$PATH" "${old_projectbase}"`
PYTHONPATH=`python ${PROJECT_ROOT}/bin/remove_from_path.py "$PYTHONPATH" "${old_projectbase}"`
fi
# add project to PYTHONPATH
if [ -z "${PYTHONPATH}" ]; then
PYTHONPATH=${PROJECT_ROOT}; export PYTHONPATH
else
PYTHONPATH=${PROJECT_ROOT}:$PYTHONPATH; export PYTHONPATH
fi
# add project to PATH
PATH=${PROJECT_ROOT}/bin:$PATH; export PATH
# add local bin to PATH (for local flake8 installations, etc)
export PATH=~/.local/bin:$PATH
unset old_projectbase
unset envscript
if [[ -z "${NO_CVMFS}" ]]
then
echo "Getting dependencies from CVMFS"
# this gives you voms-proxy-*, xrdcp and other grid tools
source /cvmfs/grid.cern.ch/etc/profile.d/setup-cvmfs-ui.sh
# ROOT 6, voms-proxy-init and other things
source /cvmfs/sft.cern.ch/lcg/views/${LCG_VERSION}/${LCG_ARCH}/setup.sh
# to fix java for the hadoop commands:
unset JAVA_HOME
python -m pip install --user -r requirements.txt
else
echo "No CVMFS available, setting up Anaconda Python"
if [ ! -d "${CMSL1T_CONDA_PATH}" ]
then
wget -nv https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O /tmp/miniconda.sh
bash /tmp/miniconda.sh -b -p ${CMSL1T_CONDA_PATH}
PATH=${CMSL1T_CONDA_PATH}/bin:$PATH; export PATH
rm -f miniconda.sh
echo "Finished conda installation, creating new conda environment"
conda config --set show_channel_urls yes
conda create -n cms python=2.7 -yq
source activate cms
conda install -y -q -c conda-forge \
matplotlib \
numpy \
"root>=6.04"
python -m pip install -U rootpy
echo "Created conda environment, installing basic dependencies"
python -m pip install -U pip
python -m pip install -r requirements.txt
conda clean -t -y
fi
source activate cms
fi
# Capture the user's site-packages directory:
USER_SITE_PACKAGES="$(python -c "import site; print(site.USER_SITE)")"
# add project to PYTHONPATH
PYTHONPATH="${USER_SITE_PACKAGES}:$PYTHONPATH"
git submodule init
git submodule update
ulimit -c 0
echo "Environment for ${PROJECT_NAME} is ready"