# adapted from http://conda.pydata.org/docs/travis.html
language: generic

# build matrices
matrix:
  include:
  - os: linux
    dist: xenial
    env: CONDA_PYTHON_VERSION=3.6
  - os: osx
    osx_image: xcode8.3
    env: CONDA_PYTHON_VERSION=3.6

addons:
      apt:
        packages:
         - swig

before_install:
 # download and install miniconda
 - echo "*************************************************"
 - echo "Building for $TRAVIS_OS_NAME"
 - echo "         for Python $CONDA_PYTHON_VERSION"
 - export PYMAJOR="3";
 - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget http://repo.continuum.io/miniconda/Miniconda$PYMAJOR-4.5.11-Linux-x86_64.sh -O miniconda.sh; fi
 - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget http://repo.continuum.io/miniconda/Miniconda$PYMAJOR-4.5.11-MacOSX-x86_64.sh -O miniconda.sh; fi
 - bash miniconda.sh -b -p $HOME/conda
 - export PATH="$HOME/conda/bin:$PATH"
 - hash -r
 - conda config --set always_yes yes --set changeps1 no
 - conda update -q conda
 # Useful for debugging any issues with conda
 - conda info -a

install:
 - echo "INSTALL CONDA"
 # (don't install conda compiler tools on linux -- this is gcc 4.8 right now)
 #- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then conda install gcc_linux-64 gcc_linux-64 ; fi
 #- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then conda install -q -c rdkit boost=1.63; fi
 - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then conda install -q py-boost=1.67.0 libboost=1.67.0 ; fi
 - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then conda install -q py-boost=1.65.1 libboost=1.65.1 ; fi
 - conda install -q numpy pillow pandas cmake eigen # matplotlib

before_script:
 # RDKit
 - echo "BEFORE SCRIPT"
 - export RDBASE=`pwd`
 - echo $RDBASE
 - export PYTHONPATH=${RDBASE}
 - export LD_LIBRARY_PATH=${RDBASE}/lib
 - export DYLD_FALLBACK_LIBRARY_PATH=${RDBASE}/lib

 - export PYTHON=`which python`
 - echo $PYTHON
 - export PY_PREFIX=`$PYTHON -c "import sys; print(sys.prefix)"`
 - echo $PY_PREFIX
 - export PY_SP_DIR=$PY_PREFIX/lib/python$CONDA_PYTHON_VERSION/site-packages
 - echo $PY_SP_DIR

script:
  - echo "SCRIPT"
  - cd $RDBASE
  - mkdir build
  - cd build
  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then  export CXX="g++" ; fi
  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then  export CC="gcc" ; fi
  - cmake $REGEX_EXTRA -D PYTHON_EXECUTABLE=$PYTHON -D BOOST_ROOT=$PY_PREFIX -D Boost_NO_SYSTEM_PATHS=ON -D RDK_BUILD_AVALON_SUPPORT=ON -D RDK_BUILD_INCHI_SUPPORT=ON -DRDK_BUILD_THREADSAFE_SSS=on -DRDK_TEST_MULTITHREADED=on -DRDK_INSTALL_STATIC_LIBS=OFF -DRDK_BUILD_SWIG_WRAPPERS=OFF -DRDK_SWIG_STATIC=OFF -DRDK_BUILD_PYTHON_WRAPPERS=ON -DRDK_BUILD_FREESASA_SUPPORT=ON ..
  - make -j2 install
  - ls "$PY_PREFIX/lib"
  - LD_LIBRARY_PATH="$PY_PREFIX/lib:$PREFIX/lib;$SRC_DIR/lib;$LD_LIBRARY_PATH" ctest -j2 --output-on-failure
