.travis.yml revision 12391:ceeca8b41e4b
1language: cpp
2dist: trusty
3sudo: false
4matrix:
5  include:
6  # This config does a few things:
7  # - Checks C++ and Python code styles (check-style.sh and flake8).
8  # - Makes sure sphinx can build the docs without any errors or warnings.
9  # - Tests setup.py sdist and install (all header files should be present).
10  # - Makes sure that everything still works without optional deps (numpy/scipy/eigen) and
11  #   also tests the automatic discovery functions in CMake (Python version, C++ standard).
12  - os: linux
13    env: STYLE DOCS PIP
14    cache: false
15    before_install:
16    - pyenv global $(pyenv whence 2to3)  # activate all python versions
17    - PY_CMD=python3
18    - $PY_CMD -m pip install --user --upgrade pip wheel
19    install:
20    - $PY_CMD -m pip install --user --upgrade sphinx sphinx_rtd_theme breathe flake8 pep8-naming pytest
21    - curl -fsSL ftp://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.12.linux.bin.tar.gz | tar xz
22    - export PATH="$PWD/doxygen-1.8.12/bin:$PATH"
23    script:
24    - tools/check-style.sh
25    - flake8
26    - $PY_CMD -m sphinx -W -b html docs docs/.build
27    - |
28      # Make sure setup.py distributes and installs all the headers
29      $PY_CMD setup.py sdist
30      $PY_CMD -m pip install --user -U ./dist/*
31      installed=$($PY_CMD -c "import pybind11; print(pybind11.get_include(True) + '/pybind11')")
32      diff -rq $installed ./include/pybind11
33    - |
34      # Barebones build
35      cmake -DCMAKE_BUILD_TYPE=Debug -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON
36      make pytest -j 2
37      make cpptest -j 2
38  # The following are regular test configurations, including optional dependencies.
39  # With regard to each other they differ in Python version, C++ standard and compiler.
40  - os: linux
41    env: PYTHON=2.7 CPP=11 GCC=4.8
42    addons:
43      apt:
44        packages: [cmake=2.\*, cmake-data=2.\*]
45  - os: linux
46    env: PYTHON=3.6 CPP=11 GCC=4.8
47    addons:
48      apt:
49        sources: [deadsnakes]
50        packages: [python3.6-dev python3.6-venv, cmake=2.\*, cmake-data=2.\*]
51  - sudo: true
52    services: docker
53    env: PYTHON=2.7 CPP=14 GCC=6 CMAKE=1
54  - sudo: true
55    services: docker
56    env: PYTHON=3.5 CPP=14 GCC=6 DEBUG=1
57  - sudo: true
58    services: docker
59    env: PYTHON=3.6 CPP=17 GCC=7
60  - os: linux
61    env: PYTHON=3.6 CPP=17 CLANG=5.0
62    addons:
63      apt:
64        sources: [deadsnakes, llvm-toolchain-trusty-5.0, ubuntu-toolchain-r-test]
65        packages: [python3.6-dev python3.6-venv clang-5.0 llvm-5.0-dev, lld-5.0]
66  - os: osx
67    osx_image: xcode7.3
68    env: PYTHON=2.7 CPP=14 CLANG CMAKE=1
69  - os: osx
70    osx_image: xcode8.3
71    env: PYTHON=3.6 CPP=14 CLANG DEBUG=1
72  # Test a PyPy 2.7 build
73  - os: linux
74    env: PYPY=5.8 PYTHON=2.7 CPP=11 GCC=4.8
75    addons:
76      apt:
77        packages: [libblas-dev, liblapack-dev, gfortran]
78  # Build in 32-bit mode and tests against the CMake-installed version
79  - sudo: true
80    services: docker
81    env: ARCH=i386 PYTHON=3.5 CPP=14 GCC=6 INSTALL=1
82    script:
83      - |
84        $SCRIPT_RUN_PREFIX sh -c "set -e
85        cmake ${CMAKE_EXTRA_ARGS} -DPYBIND11_INSTALL=1 -DPYBIND11_TEST=0
86        make install
87        cp -a tests /pybind11-tests
88        mkdir /build-tests && cd /build-tests
89        cmake ../pybind11-tests ${CMAKE_EXTRA_ARGS} -DPYBIND11_WERROR=ON
90        make pytest -j 2"
91cache:
92  directories:
93  - $HOME/.local/bin
94  - $HOME/.local/lib
95  - $HOME/.local/include
96  - $HOME/Library/Python
97before_install:
98- |
99  # Configure build variables
100  if [ "$TRAVIS_OS_NAME" = "linux" ]; then
101    if [ -n "$CLANG" ]; then
102      export CXX=clang++-$CLANG CC=clang-$CLANG
103      COMPILER_PACKAGES="clang-$CLANG llvm-$CLANG-dev"
104    else
105      if [ -z "$GCC" ]; then GCC=4.8
106      else COMPILER_PACKAGES=g++-$GCC
107      fi
108      export CXX=g++-$GCC CC=gcc-$GCC
109    fi
110    if [ "$GCC" = "6" ]; then DOCKER=${ARCH:+$ARCH/}debian:stretch
111    elif [ "$GCC" = "7" ]; then DOCKER=debian:buster
112    fi
113  elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
114    export CXX=clang++ CC=clang;
115  fi
116  if [ -n "$CPP" ]; then CPP=-std=c++$CPP; fi
117  if [ "${PYTHON:0:1}" = "3" ]; then PY=3; fi
118  if [ -n "$DEBUG" ]; then CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DCMAKE_BUILD_TYPE=Debug"; fi
119- |
120  # Initialize environment
121  set -e
122  if [ -n "$DOCKER" ]; then
123    docker pull $DOCKER
124
125    containerid=$(docker run --detach --tty \
126      --volume="$PWD":/pybind11 --workdir=/pybind11 \
127      --env="CC=$CC" --env="CXX=$CXX" --env="DEBIAN_FRONTEND=$DEBIAN_FRONTEND" \
128      --env=GCC_COLORS=\  \
129      $DOCKER)
130    SCRIPT_RUN_PREFIX="docker exec --tty $containerid"
131    $SCRIPT_RUN_PREFIX sh -c 'for s in 0 15; do sleep $s; apt-get update && apt-get -qy dist-upgrade && break; done'
132  else
133    if [ "$PYPY" = "5.8" ]; then
134      curl -fSL https://bitbucket.org/pypy/pypy/downloads/pypy2-v5.8.0-linux64.tar.bz2 | tar xj
135      PY_CMD=$(echo `pwd`/pypy2-v5.8.0-linux64/bin/pypy)
136      CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DPYTHON_EXECUTABLE:FILEPATH=$PY_CMD"
137    else
138      PY_CMD=python$PYTHON
139      if [ "$TRAVIS_OS_NAME" = "osx" ]; then
140        if [ "$PY" = "3" ]; then
141          brew install python$PY;
142        else
143          curl -fsSL https://bootstrap.pypa.io/get-pip.py | $PY_CMD - --user
144        fi
145      fi
146    fi
147    if [ "$PY" = 3 ] || [ -n "$PYPY" ]; then
148      $PY_CMD -m ensurepip --user
149    fi
150    $PY_CMD -m pip install --user --upgrade pip wheel
151  fi
152  set +e
153install:
154- |
155  # Install dependencies
156  set -e
157  if [ -n "$DOCKER" ]; then
158    if [ -n "$DEBUG" ]; then
159      PY_DEBUG="python$PYTHON-dbg python$PY-scipy-dbg"
160      CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DPYTHON_EXECUTABLE=/usr/bin/python${PYTHON}dm"
161    fi
162    $SCRIPT_RUN_PREFIX sh -c "for s in 0 15; do sleep \$s; \
163      apt-get -qy --no-install-recommends install \
164        $PY_DEBUG python$PYTHON-dev python$PY-pytest python$PY-scipy \
165        libeigen3-dev libboost-dev cmake make ${COMPILER_PACKAGES} && break; done"
166  else
167
168    if [ "$CLANG" = "5.0" ]; then
169      if ! [ -d ~/.local/include/c++/v1 ]; then
170        # Neither debian nor llvm provide a libc++ 5.0 deb; luckily it's fairly quick
171        # to build, install (and cache), so do it ourselves:
172        git clone --depth=1 https://github.com/llvm-mirror/llvm.git llvm-source
173        git clone https://github.com/llvm-mirror/libcxx.git llvm-source/projects/libcxx -b release_50
174        git clone https://github.com/llvm-mirror/libcxxabi.git llvm-source/projects/libcxxabi -b release_50
175        mkdir llvm-build && cd llvm-build
176        # Building llvm requires a newer cmake than is provided by the trusty container:
177        CMAKE_VER=cmake-3.8.0-Linux-x86_64
178        curl https://cmake.org/files/v3.8/$CMAKE_VER.tar.gz | tar xz
179        ./$CMAKE_VER/bin/cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/.local ../llvm-source
180        make -j2 install-cxxabi install-cxx
181        cp -a include/c++/v1/*cxxabi*.h ~/.local/include/c++/v1
182        cd ..
183      fi
184      export CXXFLAGS="-isystem $HOME/.local/include/c++/v1 -stdlib=libc++"
185      export LDFLAGS="-L$HOME/.local/lib -fuse-ld=lld-$CLANG"
186      export LD_LIBRARY_PATH="$HOME/.local/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
187      if [ "$CPP" = "-std=c++17" ]; then CPP="-std=c++1z"; fi
188    fi
189
190    export NPY_NUM_BUILD_JOBS=2
191    echo "Installing pytest, numpy, scipy..."
192    ${PYPY:+travis_wait 30} $PY_CMD -m pip install --user --upgrade pytest numpy scipy \
193        ${PYPY:+--extra-index-url https://imaginary.ca/trusty-pypi}
194    echo "done."
195
196    wget -q -O eigen.tar.gz https://bitbucket.org/eigen/eigen/get/3.3.3.tar.gz
197    tar xzf eigen.tar.gz
198    export CMAKE_INCLUDE_PATH="${CMAKE_INCLUDE_PATH:+:}$PWD/eigen-eigen-67e894c6cd8f"
199  fi
200  set +e
201script:
202- $SCRIPT_RUN_PREFIX cmake ${CMAKE_EXTRA_ARGS}
203    -DPYBIND11_PYTHON_VERSION=$PYTHON
204    -DPYBIND11_CPP_STANDARD=$CPP
205    -DPYBIND11_WERROR=${WERROR:-ON}
206    -DDOWNLOAD_CATCH=ON
207- $SCRIPT_RUN_PREFIX make pytest -j 2
208- $SCRIPT_RUN_PREFIX make cpptest -j 2
209- if [ -n "$CMAKE" ]; then $SCRIPT_RUN_PREFIX make test_cmake_build; fi
210after_failure: cat tests/test_cmake_build/*.log*
211after_script:
212- if [ -n "$DOCKER" ]; then docker stop "$containerid"; docker rm "$containerid"; fi
213