forked from conda/conda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtravis-install.sh
305 lines (251 loc) · 8.41 KB
/
travis-install.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
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
#!/usr/bin/env bash
# NOTE: this script should be sourced instead of executed
# turn ON immediate error termination
set -e
# turn ON verbose printing of commands/results
set -x
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # #
# # TRAVIS CI INSTALL # #
# # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
###########################################################################
# HELPER FUNCTIONS #
osx_setup() {
echo "OSX SETUP"
# as of October 24, 2016 need to use latest RVM to avoid
# shell_session_update issue
# reference:
# https://github.com/direnv/direnv/issues/210
# https://github.com/travis-ci/travis-ci/issues/6307
# https://github.com/rvm/rvm/issues/3725
rvm get head
# update Homebrew basics
brew update || brew update
# install/update openssl
if [[ $(brew list | grep openssl) ]]; then
brew outdated openssl || brew upgrade openssl
else
brew install openssl
fi
# test for shells before trying to install them
if [[ $(brew list | grep dash) ]]; then
brew outdated dash || brew upgrade dash
else
brew install dash
fi
if [[ $(brew list | grep zsh) ]]; then
brew outdated zsh || brew upgrade zsh
else
brew install zsh
fi
if [[ $(brew list | grep ksh) ]]; then
brew outdated ksh || brew upgrade ksh
else
brew install ksh
fi
if [[ $(brew list | grep tcsh) ]]; then
brew outdated tcsh || brew upgrade tcsh
else
brew install tcsh
fi
# pure csh is not available via brew, but since many users of
# csh are actually using tcsh whether they know it or not this
# is a decent substitute
if [[ $(which csh) ]]; then
:
else
ln -s "$(which tcsh)" "$(which tcsh | sed 's|tcsh|csh|')"
fi
# no posh or substitute available via brew
# install pyenv
if [[ -d "${HOME}/.pyenv" ]]; then
:
else
git clone "https://github.com/yyuu/pyenv.git" "${HOME}/.pyenv"
fi
PYENV_ROOT="${HOME}/.pyenv"
PATH=$(./shell/envvar_cleanup.bash "$PYENV_ROOT/bin:$PATH" -d)
export PATH
eval "$(pyenv init -)"
# install the specified python version
case "$PYTHON_VERSION" in
'2.7')
curl -O https://bootstrap.pypa.io/get-pip.py
python get-pip.py --user
;;
'3.4')
pyenv install 3.4.4
pyenv global 3.4.4
;;
'3.5')
pyenv install 3.5.1
pyenv global 3.5.1
;;
esac
pyenv rehash
PYTHON_EXE="$(pyenv which python)"
export PYTHON_EXE
echo "END OSX SETUP"
}
linux_setup() {
echo "LINUX SETUP"
PYTHON_EXE="$(which python)"
export PYTHON_EXE
echo "END LINUX SETUP"
}
python_install() {
echo "PYTHON INSTALL"
case "$(uname -s)" in
'Darwin')
osx_setup
;;
'Linux')
linux_setup
;;
*) ;;
esac
# install/upgrade basic dependencies
python -m pip install -U psutil ruamel.yaml pycosat pycrypto
case "${TRAVIS_PYTHON_VERSION:-PYTHON_VERSION}" in
'2.7')
python -m pip install -U enum34 futures;;
*) ;;
esac
echo "END PYTHON INSTALL"
}
flake8_extras() {
echo "FLAKE8 EXTRAS"
# install/update flake8 dependencies
python -m pip install -U flake8
echo "END FLAKE8 EXTRAS"
}
test_extras() {
echo "TEST EXTRAS"
# install/upgrade unittest dependencies
python -m pip install -U mock pytest pytest-cov pytest-timeout radon
python -m pip install -U responses anaconda-client nbformat
echo "END TEST EXTRAS"
}
miniconda_install() {
echo "MINICONDA INSTALL"
# get, install, and verify miniconda
if [[ ! -d "${HOME}/miniconda" ]]; then
if [[ ! -f "${HOME}/miniconda.sh" ]]; then
# build download url
case "$(uname -s)" in
'Darwin')
filename="Miniconda3-4.0.5-MacOSX-x86_64.sh"
;;
'Linux')
filename="Miniconda3-4.0.5-Linux-x86_64.sh"
;;
*) ;;
esac
# try download
curl "${MINICONDA_URL}${filename}" -o "${HOME}/miniconda.sh"
fi
# run install
bash "${HOME}/miniconda.sh" -bfp "${HOME}/miniconda"
fi
# check for success
if [[ ! -d "${HOME}/miniconda" ]]; then
echo "MINICONDA INSTALL FAILED"
cat "${HOME}/miniconda.log"
exit 1
fi
# update PATH
ANACONDA_PATH="${HOME}/miniconda/bin"
PATH="${ANACONDA_PATH}:${PATH}"
export PATH
hash -r
which -a conda
# this causes issues with Miniconda3 4.0.5
# python -m conda info
# this does not cause issues with Miniconda3 4.0.5
conda info
# install and verify pip
conda install -y -q pip
which -a pip
# verify python
which -a python
# disable automatic updates
conda config --set auto_update_conda false
# conda config --set always_yes yes
# conda update conda
echo "END MINICONDA INSTALL"
}
conda_build_extras() {
echo "CONDA BUILD EXTRAS"
# install conda (the repo exists at $PWD)
python utils/setup-testing.py install
conda info
# install conda-build test dependencies
conda install -y -q pytest pytest-cov pytest-timeout mock
python -m pip install pytest-capturelog pkginfo
conda install -y -q anaconda-client numpy conda-verify
conda install -y -q -c conda-forge perl pytest-xdist
conda config --set add_pip_as_python_dependency true
# install conda-build runtime dependencies
case "$(uname -s)" in
'Darwin')
conda install -y -q filelock jinja2
;;
'Linux')
conda install -y -q filelock jinja2 patchelf
;;
*) ;;
esac
# install conda-build
if [[ ! -d ./conda-build ]]; then
git clone -b "${CONDA_BUILD}" --single-branch --depth 1000 https://github.com/conda/conda-build.git
fi
pushd conda-build
python setup.py install
conda info
popd
# get conda-build test recipe
if [[ ! -d ./conda_build_test_recipe ]]; then
git clone https://github.com/conda/conda_build_test_recipe.git
fi
echo "END CONDA BUILD EXTRAS"
}
# END HELPER FUNCTIONS #
###########################################################################
###########################################################################
# "MAIN FUNCTION" #
echo "START INSTALLING"
# set globals
MINICONDA_URL="https://repo.continuum.io/miniconda/"
# TODO: if a newer build exists kill this build
# show basic environment details #
which -a python
env | sort
# remove duplicates from the $PATH #
# CSH has issues when variables get too long #
# a common error that may occur would be a "Word too long" error and is #
# probably related to the PATH variable, here we use envvar_cleanup.bash #
# to remove duplicates from the path variable before trying to run the #
# tests #
PATH=$(./shell/envvar_cleanup.bash "$PATH" -d)
export PATH
# remove any stray CONDARC #
[[ -f "${HOME}/.condarc" ]] && rm -f "${HOME}/.condarc"
# perform the appropriate install #
if [[ "${FLAKE8}" == true ]]; then
python_install
flake8_extras
elif [[ -n "${CONDA_BUILD}" ]]; then
# running anything with python -m conda in Miniconda3 4.0.5 causes
# issues, use conda directly
miniconda_install
conda_build_extras
else
python_install
test_extras
fi
echo "DONE INSTALLING"
# END "MAIN FUNCTION" #
###########################################################################