|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +UNAMESTR=`uname` |
| 6 | + |
| 7 | +make_conda() { |
| 8 | + TO_INSTALL="$@" |
| 9 | + conda create -n $VIRTUALENV --yes $TO_INSTALL |
| 10 | + source activate $VIRTUALENV |
| 11 | +} |
| 12 | + |
| 13 | +version_ge() { |
| 14 | + # The two version numbers are seperated with a new line is piped to sort |
| 15 | + # -rV. The -V activates for version number sorting and -r sorts in |
| 16 | + # decending order. If the first argument is the top element of the sort, it |
| 17 | + # is greater than or equal to the second argument. |
| 18 | + test "$(printf "${1}\n${2}" | sort -rV | head -n 1)" == "$1" |
| 19 | +} |
| 20 | + |
| 21 | +if [[ "$DISTRIB" == "conda" ]]; then |
| 22 | + |
| 23 | + TO_INSTALL="python=$PYTHON_VERSION pip \ |
| 24 | + numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION \ |
| 25 | + joblib=$JOBLIB_VERSION git" |
| 26 | + |
| 27 | + if [[ "$INSTALL_MKL" == "true" ]]; then |
| 28 | + TO_INSTALL="$TO_INSTALL mkl" |
| 29 | + else |
| 30 | + TO_INSTALL="$TO_INSTALL nomkl" |
| 31 | + fi |
| 32 | + |
| 33 | + make_conda $TO_INSTALL |
| 34 | + python -m pip install --pre -f https://sklearn-nightly.scdn8.secure.raxcdn.com scikit-learn |
| 35 | + |
| 36 | + TO_INSTALL="" |
| 37 | + |
| 38 | + if [[ -n "$PANDAS_VERSION" ]]; then |
| 39 | + TO_INSTALL="$TO_INSTALL pandas=$PANDAS_VERSION" |
| 40 | + fi |
| 41 | + |
| 42 | + if [[ -n "$KERAS_VERSION" ]]; then |
| 43 | + TO_INSTALL="$TO_INSTALL keras=$KERAS_VERSION tensorflow=1" |
| 44 | + KERAS_BACKEND=tensorflow |
| 45 | + fi |
| 46 | + |
| 47 | + if [[ -n "$TENSORFLOW_VERSION" ]]; then |
| 48 | + TO_INSTALL="$TO_INSTALL tensorflow=$TENSORFLOW_VERSION" |
| 49 | + fi |
| 50 | + |
| 51 | + if [[ "$PYTEST_VERSION" == "*" ]]; then |
| 52 | + python -m pip install pytest |
| 53 | + else |
| 54 | + python -m pip install pytest=="$PYTEST_VERSION" |
| 55 | + fi |
| 56 | + |
| 57 | + if [[ "$PYTHON_VERSION" == "*" ]]; then |
| 58 | + python -m pip install pytest-xdist |
| 59 | + fi |
| 60 | + |
| 61 | + if [[ -n "$TO_INSTALL" ]]; then |
| 62 | + conda install --yes $TO_INSTALL |
| 63 | + fi |
| 64 | + |
| 65 | + if [[ -n "$KERAS_VERSION" ]]; then |
| 66 | + python -c "import keras.backend" |
| 67 | + sed -i -e 's/"backend":[[:space:]]*"[^"]*/"backend":\ "'$KERAS_BACKEND'/g' ~/.keras/keras.json; |
| 68 | + fi |
| 69 | + |
| 70 | +elif [[ "$DISTRIB" == "ubuntu" ]]; then |
| 71 | + sudo add-apt-repository --remove ppa:ubuntu-toolchain-r/test |
| 72 | + sudo apt-get update |
| 73 | + sudo apt-get install python3-scipy libatlas3-base libatlas-base-dev libatlas-dev python3-virtualenv git |
| 74 | + python3 -m virtualenv --system-site-packages --python=python3 $VIRTUALENV |
| 75 | + source $VIRTUALENV/bin/activate |
| 76 | + python -m pip install pandas |
| 77 | + python -m pip install pytest==$PYTEST_VERSION pytest-cov joblib cython |
| 78 | + python -m pip install git+https://github.com/scikit-learn/scikit-learn.git |
| 79 | +elif [[ "$DISTRIB" == "ubuntu-32" ]]; then |
| 80 | + apt-get update |
| 81 | + apt-get install -y python3-dev python3-scipy libatlas3-base libatlas-base-dev libatlas-dev python3-virtualenv git |
| 82 | + python3 -m virtualenv --system-site-packages --python=python3 $VIRTUALENV |
| 83 | + source $VIRTUALENV/bin/activate |
| 84 | + python -m pip install pandas |
| 85 | + python -m pip install pytest==$PYTEST_VERSION pytest-cov joblib cython |
| 86 | + python -m pip install git+https://github.com/scikit-learn/scikit-learn.git |
| 87 | +elif [[ "$DISTRIB" == "conda-pip-latest" ]]; then |
| 88 | + # Since conda main channel usually lacks behind on the latest releases, |
| 89 | + # we use pypi to test against the latest releases of the dependencies. |
| 90 | + # conda is still used as a convenient way to install Python and pip. |
| 91 | + make_conda "python=$PYTHON_VERSION" |
| 92 | + python -m pip install -U pip |
| 93 | + python -m pip install numpy scipy joblib cython |
| 94 | + python -m pip install git+https://github.com/scikit-learn/scikit-learn.git |
| 95 | + python -m pip install pytest==$PYTEST_VERSION pytest-cov pytest-xdist |
| 96 | + python -m pip install pandas |
| 97 | +fi |
| 98 | + |
| 99 | +if [[ "$COVERAGE" == "true" ]]; then |
| 100 | + python -m pip install coverage codecov pytest-cov |
| 101 | +fi |
| 102 | + |
| 103 | +if [[ "$TEST_DOCSTRINGS" == "true" ]]; then |
| 104 | + python -m pip install sphinx |
| 105 | + python -m pip install -U git+https://github.com/numpy/numpydoc.git |
| 106 | +fi |
| 107 | + |
| 108 | +python --version |
| 109 | +python -c "import numpy; print('numpy %s' % numpy.__version__)" |
| 110 | +python -c "import scipy; print('scipy %s' % scipy.__version__)" |
| 111 | +python -c "\ |
| 112 | +try: |
| 113 | + import pandas |
| 114 | + print('pandas %s' % pandas.__version__) |
| 115 | +except ImportError: |
| 116 | + print('pandas not installed') |
| 117 | +" |
| 118 | +python -m pip list |
| 119 | + |
| 120 | +# Use setup.py instead of `pip install -e .` to be able to pass the -j flag |
| 121 | +# to speed-up the building multicore CI machines. |
| 122 | +python setup.py develop |
0 commit comments