# Travis-CI.org build script

# use the new containerized infrastructure
sudo: false

# Default distro, precise (12.04 LTS) has ancient python3.2 that doesn't
# support requests, required for pip3.
dist: trusty

language: c
compiler:
  - gcc
  - clang
env:
  - PY=2
  - PY=3

# Apparently the wcslib version they have (4.8.3) doesn't use pkg-config
# And netpbm include files are right in /usr/include, not in /usr/include/netpbm

script:
    - which python
    - python --version
    - which python2
    - which python3
    - mkdir -p ~/bin
    - export PATH=~/bin:${PATH}
    - ls -l $(which python$PY)
    #- ln -s $(which python$PY) ~/bin/python
    - alias python="python$PY"
    - which python
    - ls -l $(which python)
    #- cat $(which python)
    - python --version
    - which pip2
    - which pip3
    - ls -l $(which pip$PY)
    #- ln -s $(which pip$PY) ~/bin/pip
    - alias pip="pip$PY"
    - which pip
    - pip install numpy --user
    - pip install fitsio --user
    - export WCSLIB_INC="-I/usr/include/wcslib-4.20"
    - export WCSLIB_LIB="-lwcs"
    - make
    - make py
    - make extra
    - make test
    - (cd util; ./test)
    - (cd blind; ./test)
    - (cd libkd; ./test)
    - make install INSTALL_DIR=~/an
    - export PATH=${PATH}:~/an/bin
    - build-astrometry-index -d 3 -o index-9918.fits -P 18 -S mag -B 0.1 -s 0 -r 1 -I 9918 -M -i demo/tycho2-mag6.fits
    - echo -e 'add_path .\ninparallel\nindex index-9918.fits' > 99.cfg
    - solve-field --config 99.cfg demo/apod4.jpg  --continue
    - tablist demo/apod4.match
    - listhead demo/apod4.wcs
    - export PYTHONPATH=${PYTHONPATH}:~/an/lib/python
    - python -c "import astrometry.libkd.spherematch"

# install:
#   - sudo apt-get update -qq
#   - sudo apt-get install -y libnetpbm10 libnetpbm10-dev wcslib-dev libcfitsio3 libcfitsio3-dev python-numpy swig gsl-bin libgsl0-dev

addons:
  apt:
    packages:
    - libnetpbm10
    - libnetpbm10-dev
    - netpbm
    - wcslib-dev
    - libcfitsio3
    - libcfitsio3-dev
    - swig
    - gsl-bin
    - libgsl0-dev

# The trusty image py3 already (in /opt); and use pip to install numpy.
# - python3
# - python3-dev
# - python3-pip
# - python3-numpy
# - python-numpy

# ugh, no python3-pip in 'precise'
#    - python3-setuptools
#    - libgsl10-dev


