# Adapted from M. Brett's .yaml file for nipy:
# https://github.com/nipy/nipy/blob/master/.travis.yml
#
# We pretend to be erlang because we can't use the python support in
# travis-ci; it uses virtualenvs, they do not have numpy, scipy, matplotlib,
# and it is impractical to build them
language: erlang
notifications:
    email:
        - statsmodels-commits@googlegroups.com
env:
    # Enable python 2 and python 3 builds. Python3.2 available in Ubuntu 12.04.
    - PYTHON=python PYSUF=''
    - PYTHON=python3 PYSUF=3
install:
    - sudo apt-get update
    - sudo apt-get install $PYTHON-dev
    - sudo apt-get install $PYTHON-numpy
    - sudo apt-get install $PYTHON-scipy
    - sudo apt-get install $PYTHON-setuptools
    - sudo apt-get install $PYTHON-nose
    # Cython needs manual install under Python 3
    - if [ "${PYSUF}" == "3" ]; then
         wget http://cython.org/release/Cython-0.17.1.tar.gz ;
         tar xfvz Cython-0.17.1.tar.gz ;
         cd Cython-0.17.1 ;
         sudo python3 setup.py install ;
         cd .. ;
      else
         sudo apt-get install cython ;
      fi
    - echo ${DISTRIB_CODENAME}
    - wget -O- http://neuro.debian.net/lists/precise.us-nh.full | sudo tee /etc/apt/sources.list.d/neurodebian.sources.list
    - sudo apt-key adv --recv-keys --keyserver pgp.mit.edu 2649A5A9
    - sudo apt-get update -qq
    - sudo apt-get install $PYTHON-dateutil
    - sudo apt-get --no-install-recommends install $PYTHON-pandas
    - sudo apt-get --no-install-recommends install $PYTHON-pandas-lib
    - sudo easy_install$PYSUF -U patsy
    - if [ "${PYSUF}" != "3" ]; then sudo pip install coverage; fi
    - if [ "${PYSUF}" != "3" ]; then sudo pip install coveralls; fi
script:
    - SRCDIR=$PWD
    - sudo $PYTHON setup.py install
    # Ubuntu 12.04 installs statsmodels under the wrong path for Python 3
    - if [ "${PYSUF}" == "3" ]; then
         sudo mv /usr/local/lib/python3.2/dist-packages/statsmodels-*/statsmodels /usr/local/lib/python3.2/dist-packages/statsmodels ;
         sudo rm -rf /usr/lib/python3.2/dist-packages/statsmodels-* ;
      fi
    # statsmodels was installed "system-wide" thus cd under dedicated
    # travis-test/ directory to not try using local version without built extensions
    - mkdir -p "${SRCDIR}/travis-test"; cd "${SRCDIR}/travis-test"
    # Compose a script to run testing with coverage
    - echo 'import statsmodels as sm; a=sm.test(); import sys; sys.exit((len(a.failures)+len(a.errors))>0)' > test.py
    - if [ "${PYSUF}" != "3" ]; then coverage run --rcfile=${SRCDIR}/.travis_coveragerc test.py; else $PYTHON test.py; fi
after_success:
    - if [ "${PYSUF}" != "3" ]; then coveralls; fi
