forked from HEP-FCC/FCCAnalyses
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
173 lines (155 loc) · 5.67 KB
/
Copy pathsetup.sh
File metadata and controls
173 lines (155 loc) · 5.67 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
if [ "${0}" == "${BASH_SOURCE[0]}" ]; then
echo "----> ERROR: This script is meant to be sourced!"
exit 1
fi
unset HELP
unset LATEST
unset NIGHTLIES
unset PINNED
unset FROMBUILD
unset STACK_SELECTION_MADE
POSITIONAL_ARGS=()
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
HELP="TRUE"
shift
;;
-l|--latest)
LATEST="TRUE"
STACK_SELECTION_MADE="TRUE"
shift
;;
-n|--nightlies)
NIGHTLIES="TRUE"
STACK_SELECTION_MADE="TRUE"
shift
;;
-p|--pinned)
PINNED="TRUE"
STACK_SELECTION_MADE="TRUE"
shift
;;
-b|--from-build)
FROMBUILD="TRUE"
STACK_SELECTION_MADE="TRUE"
shift
;;
-*)
echo "ERROR: Unknown option ${1}"
exit 1
;;
*)
POSITIONAL_ARGS+=("${1}")
shift
;;
esac
done
set -- "${POSITIONAL_ARGS[@]}"
if [ -n "${HELP}" ]; then
echo "USAGE: source setup.sh [-h, -l, -n, -p, -b]"
echo " -h/--help Show this help and exit"
echo " -l/--latest Setup the latest release of the Key4hep stack"
echo " -n/--nightlies Setup the latest nightlies version of the Key4hep stack"
echo " -p/--pinned Setup the pinned version of the Key4hep stack"
echo " -b/--from-build Setup the version of the Key4hep stack used for the latest local build"
echo
echo "The setup script defaults to using the pinned stack. If the pinned stack is not set,"
echo "the latest stable release is used instead."
return
fi
if [ -n "${FCCANA_LOCAL_DIR}" ]; then
echo "----> WARNING: Local FCCAnalyses environment already set up."
echo " Skipping its setup..."
return
fi
# Determining the location of this setup script
FCCANA_LOCAL_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
echo "----> INFO: Setting up Key4hep stack..."
if [ -n "${KEY4HEP_STACK}" ]; then
echo "----> INFO: Key4hep stack already set up. Skipping its setup..."
else
# Sourcing of the stack
if [ -n "${STACK_SELECTION_MADE}" ]; then
if [ -n "${LATEST}" ]; then
echo "----> INFO: Sourcing latest Key4hep stack release..."
source /cvmfs/sw.hsf.org/key4hep/setup.sh
fi
if [ -n "${NIGHTLIES}" ]; then
echo "----> INFO: Sourcing latest nightlies Key4hep stack..."
source /cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh
fi
if [ -n "${PINNED}" ]; then
if [ -f "${FCCANA_LOCAL_DIR}/.fccana/stack_pin" ]; then
STACK_PATH=$(<${FCCANA_LOCAL_DIR}/.fccana/stack_pin)
# TODO: Legacy pin location, remove after Jun 2026
elif [ -f "${FCCANA_LOCAL_DIR}/.fccana/stackpin" ]; then
STACK_PATH=$(<${FCCANA_LOCAL_DIR}/.fccana/stackpin)
else
echo "----> ERROR: The Key4hep stack is not pinned! Aborting..."
return 1
fi
echo "----> INFO: Sourcing pinned Key4hep stack..."
echo " ${STACK_PATH}"
source ${STACK_PATH}
fi
if [ -n "${FROMBUILD}" ]; then
echo "----> INFO: Sourcing Key4hep stack used for the latest build..."
if [ -f "${FCCANA_LOCAL_DIR}/.fccana/stack_build" ]; then
STACK_PATH=$(<${FCCANA_LOCAL_DIR}/.fccana/stack_build)
echo " ${STACK_PATH}"
source ${STACK_PATH}
else
echo "----> ERROR: The information about the Key4hep stack used for building not found!"
echo " Try sourcing the Key4hep stack using other options and rebuilding"
echo " FCCAnalyses using 'fccanalysis build' command."
echo " Aborting..."
return 1
fi
fi
else
if [ -f "${FCCANA_LOCAL_DIR}/.fccana/stack_pin" ]; then
STACK_PATH=$(<${FCCANA_LOCAL_DIR}/.fccana/stack_pin)
echo "----> INFO: Sourcing pinned Key4hep stack..."
echo " ${STACK_PATH}"
source ${STACK_PATH}
# TODO: Legacy pin location, remove after Jun 2026
elif [ -f "${FCCANA_LOCAL_DIR}/.fccana/stackpin" ]; then
STACK_PATH=$(<${FCCANA_LOCAL_DIR}/.fccana/stackpin)
echo "----> INFO: Sourcing pinned Key4hep stack..."
echo " ${STACK_PATH}"
source ${STACK_PATH}
else
echo "----> INFO: Sourcing latest Key4hep stack release..."
source /cvmfs/sw.hsf.org/key4hep/setup.sh
fi
fi
fi
if [ -z "${KEY4HEP_STACK}" ]; then
echo "----> ERROR: Key4hep stack not setup correctly! Aborting..."
return 1
fi
echo "----> INFO: Setting up local FCCAnalyses environment variables..."
export FCCANA_LOCAL_DIR
export PYTHONPATH=${FCCANA_LOCAL_DIR}/python:${PYTHONPATH}
export PYTHONPATH=${FCCANA_LOCAL_DIR}/install/python:${PYTHONPATH}
export PYTHONPATH=${FCCANA_LOCAL_DIR}/install/share/examples:${PYTHONPATH}
export PATH=${FCCANA_LOCAL_DIR}/bin:${PATH}
export PATH=${FCCANA_LOCAL_DIR}/install/bin:${PATH}
export LD_LIBRARY_PATH=${FCCANA_LOCAL_DIR}/install/lib64:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=${FCCANA_LOCAL_DIR}/install/lib:${LD_LIBRARY_PATH}
export CMAKE_PREFIX_PATH=${FCCANA_LOCAL_DIR}/install:${CMAKE_PREFIX_PATH}
export ROOT_INCLUDE_PATH=$(fastjet-config --prefix)/include:${ROOT_INCLUDE_PATH}
export ROOT_INCLUDE_PATH=${FCCANA_LOCAL_DIR}/install/include:${ROOT_INCLUDE_PATH}
export ONNXRUNTIME_ROOT_DIR=`python -c "import onnxruntime; print(onnxruntime.__path__[0]+'/../../../..')" 2> /dev/null`
if [ -z "${ONNXRUNTIME_ROOT_DIR}" ]; then
echo "----> WARNING: ONNX Runtime not found! Related analyzers won't be build..."
else
export LD_LIBRARY_PATH=${ONNXRUNTIME_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
fi
export MANPATH=${FCCANA_LOCAL_DIR}/man:${MANPATH}
export MANPATH=${FCCANA_LOCAL_DIR}/install/share/man:${MANPATH}
export MYPYPATH=${FCCANA_LOCAL_DIR}/python:${MYPYPATH}
export FCCDICTSDIR=/cvmfs/fcc.cern.ch/FCCDicts:${FCCDICTSDIR}
# Suppress .Snapshot info message
export ROOT_RDF_SNAPSHOT_INFO=0