forked from fermiPy/fermipy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
condainstall.sh
127 lines (103 loc) · 3.24 KB
/
condainstall.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
#!/usr/bin/env bash
# Default python version
if [[ -z $PYTHON_VERSION ]]; then
PYTHON_VERSION=2.7
fi
# Default conda download
if [[ -z $CONDA_DOWNLOAD ]]; then
if [[ `uname` == "Darwin" ]]; then
echo "Detected Mac OS X..."
if [[ $PYTHON_VERSION == "2.7" ]]; then
CONDA_DOWNLOAD=Miniconda2-latest-MacOSX-x86_64.sh
else
CONDA_DOWNLOAD=Miniconda3-latest-MacOSX-x86_64.sh
fi
else
echo "Detected Linux..."
if [[ $PYTHON_VERSION == "2.7" ]]; then
CONDA_DOWNLOAD=Miniconda2-latest-Linux-x86_64.sh
else
CONDA_DOWNLOAD=Miniconda3-latest-Linux-x86_64.sh
fi
fi
fi
# Default conda deps
if [[ -z $CONDA_DEPS ]]; then
CONDA_DEPS='scipy matplotlib pyyaml numpy astropy gammapy healpy astropy-healpix'
fi
# Default conda path
if [[ -z $CONDA_PATH ]]; then
CONDA_PATH=$HOME/miniconda
fi
# Default conda env
if [[ -z $FERMIPY_CONDA_ENV ]]; then
FERMIPY_CONDA_ENV=fermipy
fi
# Default fermitools conda channels
if [[ -z $FERMI_CONDA_CHANNELS ]]; then
FERMI_CONDA_CHANNELS="-c conda-forge/label/cf201901 -c fermi"
fi
# Default conda channels
if [[ -z $CONDA_CHANNELS ]]; then
CONDA_CHANNELS="conda-forge"
fi
# Default fermitools install
if [[ -z $ST_INSTALL ]]; then
ST_INSTALL="conda install -y --name $FERMIPY_CONDA_ENV $FERMI_CONDA_CHANNELS -c $CONDA_CHANNELS fermitools"
fi
# Default install command
if [[ -z $INSTALL_CMD ]]; then
INSTALL_CMD="conda install -y --name $FERMIPY_CONDA_ENV -c $CONDA_CHANNELS fermipy"
fi
if [ ! -d "$CONDA_PATH/bin" ]; then
echo Creating a new conda installation under $CONDA_PATH
curl -o miniconda.sh -L http://repo.continuum.io/miniconda/$CONDA_DOWNLOAD
bash miniconda.sh -b -p $CONDA_PATH
rc=$?
rm -f miniconda.sh
if [[ $rc != 0 ]]; then
exit $rc
fi
else
echo "Using existing conda installation under $CONDA_PATH"
fi
echo "CONDA_PATH=$CONDA_PATH"
echo "CONDA_DOWNLOAD=$CONDA_DOWNLOAD"
echo "FERMIPY_CONDA_ENV=$FERMIPY_CONDA_ENV"
echo "FERMI_CONDA_CHANNELS=$FERMI_CONDA_CHANNELS"
echo "CONDA_DEPS=$CONDA_DEPS"
echo "CONDA2_DEPS=$CONDA2_DEPS"
echo "PIP_DEPS=$PIP_DEPS"
echo "INSTALL_CMD=$INSTALL_CMD"
echo "ST_INSTALL=$ST_INSTALL"
# Make sure we have conda setup
. $CONDA_PATH/etc/profile.d/conda.sh
# First we update conda and make an env if needed
if [ ! -d $CONDA_PATH/envs/$FERMIPY_CONDA_ENV ]; then
echo "Creating environment $FERMIPY_CONDA_ENV for fermipy"
conda update -q conda -y
conda create --name $FERMIPY_CONDA_ENV $FERMI_CONDA_CHANNELS -y python=$PYTHON_VERSION
else
echo "Using existing environment $FERMIPY_CONDA_ENV"
fi
conda activate $FERMIPY_CONDA_ENV
# Install the science tools, if requested
if [[ -n $ST_INSTALL ]]; then
$ST_INSTALL
fi
# Ok, now we install fermipy dependencies
conda install -n $FERMIPY_CONDA_ENV -y -c conda-forge $CONDA_DEPS
# Install extra conda deps if needed
if [[ -n $CONDA2_DEPS ]]; then
conda install -n $FERMIPY_CONDA_ENV -y -c conda-forge $CONDA2_DEPS
fi
# Install stuff from pip (for travis coverage testing)
if [[ -n $PIP_DEPS ]]; then
python -m pip install $PIP_DEPS
fi
source condasetup.sh
# We don't set this up by default. Let the user specify how to do it.
# This is just here from the travis testing
if [[ -n $INSTALL_CMD ]]; then
$INSTALL_CMD
fi