forked from fermi-lat/Fermitools-conda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
activate.csh
117 lines (89 loc) · 3.55 KB
/
activate.csh
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
#!/bin/tcsh
set condaname="fermitools"
# This instructs the Fermi ST where to find their data
setenv INST_DIR ${CONDA_PREFIX}/share/$condaname
setenv FERMI_DIR ${INST_DIR}
setenv BASE_DIR ${INST_DIR}
setenv EXTFILESSYS ${CONDA_PREFIX}/share/$condaname/refdata/fermi
setenv GENERICSOURCESDATAPATH ${CONDA_PREFIX}/share/$condaname/data/genericSources
setenv TIMING_DIR ${CONDA_PREFIX}/share/$condaname/refdata/fermi/jplephem
setenv PFILES ${CONDA_PREFIX}/share/$condaname/syspfiles
# Keep a copy of the current path so we can restore
# upon deactivation
setenv FERMI_OLD_PATH $PATH
# Keep a copy of the CALDB path if it exists so
# we can restore upon deactivation
if ($?CALDB) then
setenv CALDB_OLD_PATH $CALDB
endif
# Set necessary CALDB variables
setenv CALDBALIAS $FERMI_DIR/data/caldb/software/tools/alias_config.fits
setenv CALDBCONFIG $FERMI_DIR/data/caldb/software/tools/caldb.config
setenv CALDBROOT $FERMI_DIR/data/caldb
setenv CALDB $FERMI_DIR/data/caldb
# Add path for the ST binaries
setenv PATH ${CONDA_PREFIX}/bin/${condaname}:${PATH}
# Setup PFILES
# Save old value (this will be the empty string if
# PFILES is not set)
setenv FERMI_OLD_PFILES $PFILES
if (! $?PFILES) then
# PFILES is unset, set it appropriately
`mkdir -p $HOME/pfiles`
setenv PFILES ".:${HOME}/pfiles;${INST_DIR}/syspfiles"
else
if ("$PFILES" =~ "*;*") then
# current value already contains a ';', which
# separates read-write pfiles path to read-only
# pfiles path. Just add the ST one
setenv PFILES "${PFILES}:${INST_DIR}/syspfiles"
else
# Current value doesn't have any read-only
# pfiles path. Add the ST one.
setenv PFILES "${PFILES};${INST_DIR}/syspfiles"
endif
endif
# Make sure there is no ROOTSYS (which would confuse ROOT)
unsetenv ROOTSYS
# Check whether the .rootrc file exists in the user home,
# if not create it
if ( -f ${HOME}/.rootrc ) then
# Make it read/write
chmod u+rw ${HOME}/.rootrc
else
# File does not exist. Copy the system.rootrc file
cp ${CONDA_PREFIX}/etc/root/system.rootrc ${HOME}/.rootrc
# Make it read/write
chmod u+rw ${HOME}/.rootrc
endif
# We need to make sure that the path to the ST library dir is
# contained in the paths that ROOT will search for libraries,
# because the dynamic loader of ROOT does not honor RPATH
cat << EOF | root -b -l
// I am using "default" as default value because I was having problems
// using the empty string.
TString old_value=gEnv->GetValue("Unix.*.Root.DynamicPath", "default");
// The formatting with the { at the end of the line is NECESSARY
// for this to work properly (as this is input for the stdin of
// root)
if(!old_value.Contains("lib/${condaname}")) {
TString new_value = old_value + TString(":${CONDA_PREFIX}/lib/${condaname}/");
gEnv->SetValue("Unix.*.Root.DynamicPath", new_value);
gEnv->SaveLevel(kEnvUser);
}
exit();
EOF
# Add aliases for python executables
set sitepackagesdir=`python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"`
alias gtburst "python $sitepackagesdir/$condaname/gtburst.py"
alias ModelEditor "python $sitepackagesdir/$condaname/ModelEditor.py"
alias ObsSim "python $sitepackagesdir/$condaname/ObsSim.py"
# # Issue warnings if PYTHONPATH and/or LD_LIBRARY_PATH are set
if ($?LD_LIBRARY_PATH) then
# Issue warning
echo "You have LD_LIBRARY_PATH set. This might interfere with the correct functioning of conda and the Fermi ST"
endif
if ($?PYTHONPATH) then
# Issue warning
echo "You have PYTHONPATH set. This might interfere with the correct functioning of conda and the Fermi ST"
endif