/
install.sh
executable file
·107 lines (94 loc) · 3.79 KB
/
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
#!/bin/bash
# This script is meant to be called by the "install" step defined in
# .travis.yml. See http://docs.travis-ci.com/ for more details.
# The behavior of the script is controlled by environment variabled defined
# in the .travis.yml in the top level folder of the project.
#
# This script is adapted from a similar script from the scikit-learn repository.
#
# License: 3-clause BSD
set -e
# Fix the compilers to workaround avoid having the Python 3.4 build
# lookup for g++44 unexpectedly.
export CC=gcc
export CXX=g++
create_new_venv() {
# At the time of writing numpy 1.9.1 is included in the travis
# virtualenv but we want to be in control of the numpy version
# we are using for example through apt-get install
deactivate
virtualenv --system-site-packages testvenv
source testvenv/bin/activate
pip install nose
}
print_conda_requirements() {
# Echo a conda requirement string for example
# "pip nose python='.7.3 scikit-learn=*". It has a hardcoded
# list of possible packages to install and looks at _VERSION
# environment variables to know whether to install a given package and
# if yes which version to install. For example:
# - for numpy, NUMPY_VERSION is used
# - for scikit-learn, SCIKIT_LEARN_VERSION is used
TO_INSTALL_ALWAYS="pip nose pillow"
REQUIREMENTS="$TO_INSTALL_ALWAYS"
TO_INSTALL_MAYBE="python numpy scipy matplotlib scikit-learn sympy scikit-image pandas seaborn statsmodels"
for PACKAGE in $TO_INSTALL_MAYBE; do
# Capitalize package name and add _VERSION
PACKAGE_VERSION_VARNAME="${PACKAGE^^}_VERSION"
# replace - by _, needed for scikit-learn for example
PACKAGE_VERSION_VARNAME="${PACKAGE_VERSION_VARNAME//-/_}"
# dereference $PACKAGE_VERSION_VARNAME to figure out the
# version to install
PACKAGE_VERSION="${!PACKAGE_VERSION_VARNAME}"
if [ -n "$PACKAGE_VERSION" ]; then
REQUIREMENTS="$REQUIREMENTS $PACKAGE=$PACKAGE_VERSION"
fi
done
echo $REQUIREMENTS
}
create_new_conda_env() {
# Deactivate the travis-provided virtual environment and setup a
# conda-based environment instead
deactivate
# Use the miniconda installer for faster download / install of conda
# itself
wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh \
-O miniconda.sh
chmod +x miniconda.sh && ./miniconda.sh -b
export PATH=/home/travis/miniconda2/bin:$PATH
conda update --yes conda
# Configure the conda environment and put it in the path using the
# provided versions
REQUIREMENTS=$(print_conda_requirements)
echo "conda requirements string: $REQUIREMENTS"
conda create -n testenv --yes $REQUIREMENTS
source activate testenv
conda install --yes libgfortran=1
if [[ "$INSTALL_MKL" == "true" ]]; then
# Make sure that MKL is used
conda install --yes mkl
else
# Make sure that MKL is not used
conda remove --yes --features mkl || echo "MKL not installed"
fi
}
if [[ "$DISTRIB" == "neurodebian" ]]; then
create_new_venv
bash <(wget -q -O- http://neuro.debian.net/_files/neurodebian-travis.sh)
sudo apt-get install -qq python-scipy python-nose python-nibabel python-sklearn
elif [[ "$DISTRIB" == "conda" ]]; then
create_new_conda_env
# Note: nibabel is in setup.py install_requires so nibabel will
# always be installed eventually. Defining NIBABEL_VERSION is only
# useful if you happen to want a specific nibabel version rather
# than the latest available one.
if [ -n "$NIBABEL_VERSION" ]; then
pip install nibabel=="$NIBABEL_VERSION"
fi
else
echo "Unrecognized distribution ($DISTRIB); cannot setup travis environment."
exit 1
fi
if [[ "$COVERAGE" == "true" ]]; then
pip install coverage coveralls
fi