diff --git a/.gitignore b/.gitignore index 2873e01c7aed4ae631d9df64d054607ff3f769de..ba22e7b114e1f73df0ca7c50c1f225d9efda6af3 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,6 @@ MANIFEST # Per-project virtualenvs .venv*/ +.ninja_deps +.ninja_log +build.ninja diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..986a81fea98bd35c451be7d4824fb128fef9f897 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,35 @@ +# Travis configuration file using the build matrix feature +# Read more under http://docs.travis-ci.com/user/build-configuration/ +# THIS SCRIPT IS SUPPOSED TO BE AN EXAMPLE. MODIFY IT ACCORDING TO YOUR NEEDS! + +sudo: false +language: python +virtualenv: + system_site_packages: false +before_install: + - sudo apt-get install -y ninja-build build-essential +addons: + apt: + update: true +matrix: + fast_finish: true + include: + - python: 3.6 + env: DISTRIB="ubuntu" TOX_PYTHON_VERSION="py36" COVERAGE="true" + - env: DISTRIB="conda" PYTHON_VERSION="3.6" COVERAGE="false" +install: + - source tests/travis_install.sh +before_script: + - git config --global user.email "you@example.com" + - git config --global user.name "Your Name" +script: + - pip install -e . + - python setup.py test +after_success: + - if [[ "$COVERAGE" == "true" ]]; then coveralls || echo "failed"; codecov; fi +after_script: + - travis-cleanup +cache: + pip: true + directories: + - $HOME/miniconda diff --git a/tests/lbm/backends/_pytorch.py b/tests/lbm/backends/_pytorch.py index 9f80c0885db18239266aa7655488190c537e36ef..c131091f1824bf562a868e0fe9e41e6746dba1b0 100644 --- a/tests/lbm/backends/_pytorch.py +++ b/tests/lbm/backends/_pytorch.py @@ -7,7 +7,7 @@ try: import pycuda.autoinit import pycuda.gpuarray import pycuda.driver -except: +except Exception: pass diff --git a/tests/travis_install.sh b/tests/travis_install.sh new file mode 100644 index 0000000000000000000000000000000000000000..fab0165f32ee8330c938cc1bf31581feea72f336 --- /dev/null +++ b/tests/travis_install.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# This script is meant to be called by the "install" step defined in +# .travis.yml. See http://docs.travis-ci.com/ for more details. +# The behavior of the script is controlled by environment variabled defined +# in the .travis.yml in the top level folder of the project. +# +# This script is inspired by Scikit-Learn (http://scikit-learn.org/) +# +# THIS SCRIPT IS SUPPOSED TO BE AN EXAMPLE. MODIFY IT ACCORDING TO YOUR NEEDS! + +set -e + +if [[ "$DISTRIB" == "conda" ]]; then + # Deactivate the travis-provided virtual environment and setup a + # conda-based environment instead + deactivate + + if [[ -f "$HOME/miniconda/bin/conda" ]]; then + echo "Skip install conda [cached]" + else + # By default, travis caching mechanism creates an empty dir in the + # beginning of the build, but conda installer aborts if it finds an + # existing folder, so let's just remove it: + rm -rf "$HOME/miniconda" + + # Use the miniconda installer for faster download / install of conda + # itself + wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh \ + -O miniconda.sh + chmod +x miniconda.sh && ./miniconda.sh -b -p $HOME/miniconda + fi + export PATH=$HOME/miniconda/bin:$PATH + # Make sure to use the most updated version + conda update --yes conda + + # Configure the conda environment and put it in the path using the + # provided versions + # (prefer local venv, since the miniconda folder is cached) + conda create -p ./.venv --yes python=${PYTHON_VERSION} pip virtualenv + source activate ./.venv +fi + +# for all +pip install -U pip setuptools +pip install tox +pip install codecov +# use newest pystencils +pip install git+https://github.com/mabau/pystencils.git + +if [[ "$COVERAGE" == "true" ]]; then + pip install -U pytest-cov pytest-virtualenv coverage coveralls flake8 +fi + + +travis-cleanup() { + printf "Cleaning up environments ... " # printf avoids new lines + if [[ "$DISTRIB" == "conda" ]]; then + # Force the env to be recreated next time, for build consistency + source deactivate + conda remove -p ./.venv --all --yes + rm -rf ./.venv + fi + echo "DONE" +}