|
| 1 | +#!/bin/sh |
| 2 | +set -ex |
| 3 | + |
| 4 | +# setup env |
| 5 | +if [ -r /usr/lib/libeatmydata/libeatmydata.so ]; then |
| 6 | + # much faster package installation |
| 7 | + export LD_PRELOAD=/usr/lib/libeatmydata/libeatmydata.so |
| 8 | +fi |
| 9 | + |
| 10 | + |
| 11 | +setup_base() |
| 12 | +{ |
| 13 | + # We used to use 'setup.py install' here, but that has the terrible |
| 14 | + # behaviour that if a copy of the package is already installed in |
| 15 | + # the install location, then the new copy just gets dropped on top |
| 16 | + # of it. Travis typically has a stable numpy release pre-installed, |
| 17 | + # and if we don't remove it, then we can accidentally end up |
| 18 | + # e.g. running old test modules that were in the stable release but |
| 19 | + # have been removed from master. (See gh-2765, gh-2768.) Using 'pip |
| 20 | + # install' also has the advantage that it tests that numpy is 'pip |
| 21 | + # install' compatible, see e.g. gh-2766... |
| 22 | + pip install . |
| 23 | +} |
| 24 | + |
| 25 | +setup_chroot() |
| 26 | +{ |
| 27 | + # this can all be replaced with: |
| 28 | + # apt-get install libpython2.7-dev:i386 |
| 29 | + # CC="gcc -m32" LDSHARED="gcc -m32 -shared" LDFLAGS="-m32 -shared" linux32 python setup.py build |
| 30 | + # when travis updates to ubuntu 14.04 |
| 31 | + DIR=$1 |
| 32 | + set -u |
| 33 | + sudo apt-get -qq -y --force-yes install debootstrap eatmydata |
| 34 | + sudo debootstrap --variant=buildd --include=fakeroot,build-essential --arch=$ARCH --foreign $DIST $DIR |
| 35 | + sudo chroot $DIR ./debootstrap/debootstrap --second-stage |
| 36 | + sudo rsync -a $TRAVIS_BUILD_DIR $DIR/ |
| 37 | + echo deb http://archive.ubuntu.com/ubuntu/ saucy main restricted universe multiverse | sudo tee -a $DIR/etc/apt/sources.list |
| 38 | + echo deb http://archive.ubuntu.com/ubuntu/ saucy-updates main restricted universe multiverse | sudo tee -a $DIR/etc/apt/sources.list |
| 39 | + echo deb http://security.ubuntu.com/ubuntu saucy-security main restricted universe multiverse | sudo tee -a $DIR/etc/apt/sources.list |
| 40 | + sudo chroot $DIR bash -c "apt-get update" |
| 41 | + sudo chroot $DIR bash -c "apt-get install -qq -y --force-yes eatmydata" |
| 42 | + echo /usr/lib/libeatmydata/libeatmydata.so | sudo tee -a $DIR/etc/ld.so.preload |
| 43 | + sudo chroot $DIR bash -c "apt-get install -qq -y --force-yes libatlas-dev libatlas-base-dev gfortran python-dev python-nose python-pip" |
| 44 | +} |
| 45 | + |
| 46 | +setup_bento() |
| 47 | +{ |
| 48 | + export CI_ROOT=$PWD |
| 49 | + cd .. |
| 50 | + |
| 51 | + # Waf |
| 52 | + wget http://waf.googlecode.com/files/waf-1.7.13.tar.bz2 |
| 53 | + tar xjvf waf-1.7.13.tar.bz2 |
| 54 | + cd waf-1.7.13 |
| 55 | + python waf-light |
| 56 | + export WAFDIR=$PWD |
| 57 | + cd .. |
| 58 | + |
| 59 | + # Bento |
| 60 | + wget https://github.com/cournape/Bento/archive/master.zip |
| 61 | + unzip master.zip |
| 62 | + cd Bento-master |
| 63 | + python bootstrap.py |
| 64 | + export BENTO_ROOT=$PWD |
| 65 | + cd .. |
| 66 | + |
| 67 | + cd $CI_ROOT |
| 68 | + |
| 69 | + # In-place numpy build |
| 70 | + $BENTO_ROOT/bentomaker build -i -j |
| 71 | + |
| 72 | + # Prepend to PYTHONPATH so tests can be run |
| 73 | + export PYTHONPATH=$PWD:$PYTHONPATH |
| 74 | +} |
| 75 | + |
| 76 | +run_test() |
| 77 | +{ |
| 78 | + # We change directories to make sure that python won't find the copy |
| 79 | + # of numpy in the source directory. |
| 80 | + mkdir -p empty |
| 81 | + cd empty |
| 82 | + INSTALLDIR=$(python -c "import os; import numpy; print(os.path.dirname(numpy.__file__))") |
| 83 | + export PYTHONWARNINGS=default |
| 84 | + python ../tools/test-installed-numpy.py # --mode=full |
| 85 | + # - coverage run --source=$INSTALLDIR --rcfile=../.coveragerc $(which python) ../tools/test-installed-numpy.py |
| 86 | + # - coverage report --rcfile=../.coveragerc --show-missing |
| 87 | +} |
| 88 | + |
| 89 | +if [ "$USE_CHROOT" != "1" ] && [ "$USE_BENTO" != "1" ]; then |
| 90 | + setup_base |
| 91 | + run_test |
| 92 | +elif [ -n "$USE_CHROOT" ] && [ $# -eq 0 ]; then |
| 93 | + DIR=/chroot |
| 94 | + setup_chroot $DIR |
| 95 | + # run again in chroot with this time testing |
| 96 | + sudo linux32 chroot $DIR bash -c "cd numpy && $0 test" |
| 97 | +elif [ -n "$USE_BENTO" ] && [ $# -eq 0 ]; then |
| 98 | + setup_bento |
| 99 | + # run again this time testing |
| 100 | + $0 test |
| 101 | +else |
| 102 | + run_test |
| 103 | +fi |
| 104 | + |
0 commit comments