• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1language: cpp
2matrix:
3  include:
4  # This config does a few things:
5  # - Checks C++ and Python code styles (check-style.sh and flake8).
6  # - Makes sure sphinx can build the docs without any errors or warnings.
7  # - Tests setup.py sdist and install (all header files should be present).
8  # - Makes sure that everything still works without optional deps (numpy/scipy/eigen) and
9  #   also tests the automatic discovery functions in CMake (Python version, C++ standard).
10  - os: linux
11    dist: xenial # Necessary to run doxygen 1.8.15
12    name: Style, docs, and pip
13    cache: false
14    before_install:
15    - pyenv global $(pyenv whence 2to3)  # activate all python versions
16    - PY_CMD=python3
17    - $PY_CMD -m pip install --user --upgrade pip wheel setuptools
18    install:
19    - $PY_CMD -m pip install --user --upgrade sphinx sphinx_rtd_theme breathe flake8 pep8-naming pytest
20    - curl -fsSL https://sourceforge.net/projects/doxygen/files/rel-1.8.15/doxygen-1.8.15.linux.bin.tar.gz/download | tar xz
21    - export PATH="$PWD/doxygen-1.8.15/bin:$PATH"
22    script:
23    - tools/check-style.sh
24    - flake8
25    - $PY_CMD -m sphinx -W -b html docs docs/.build
26    - |
27      # Make sure setup.py distributes and installs all the headers
28      $PY_CMD setup.py sdist
29      $PY_CMD -m pip install --user -U ./dist/*
30      installed=$($PY_CMD -c "import pybind11; print(pybind11.get_include(True) + '/pybind11')")
31      diff -rq $installed ./include/pybind11
32    - |
33      # Barebones build
34      cmake -DCMAKE_BUILD_TYPE=Debug -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DPYTHON_EXECUTABLE=$(which $PY_CMD) .
35      make pytest -j 2
36      make cpptest -j 2
37  # The following are regular test configurations, including optional dependencies.
38  # With regard to each other they differ in Python version, C++ standard and compiler.
39  - os: linux
40    dist: trusty
41    name: Python 2.7, c++11, gcc 4.8
42    env: PYTHON=2.7 CPP=11 GCC=4.8
43    addons:
44      apt:
45        packages:
46          - cmake=2.\*
47          - cmake-data=2.\*
48  - os: linux
49    dist: trusty
50    name: Python 3.6, c++11, gcc 4.8
51    env: PYTHON=3.6 CPP=11 GCC=4.8
52    addons:
53      apt:
54        sources:
55          - deadsnakes
56        packages:
57          - python3.6-dev
58          - python3.6-venv
59          - cmake=2.\*
60          - cmake-data=2.\*
61  - os: linux
62    dist: trusty
63    env: PYTHON=2.7 CPP=14 GCC=6 CMAKE=1
64    name: Python 2.7, c++14, gcc 6, CMake test
65    addons:
66      apt:
67        sources:
68          - ubuntu-toolchain-r-test
69        packages:
70          - g++-6
71  - os: linux
72    dist: trusty
73    name: Python 3.5, c++14, gcc 6, Debug build
74    # N.B. `ensurepip` could be installed transitively by `python3.5-venv`, but
75    # seems to have apt conflicts (at least for Trusty). Use Docker instead.
76    services: docker
77    env: DOCKER=debian:stretch PYTHON=3.5 CPP=14 GCC=6 DEBUG=1
78  - os: linux
79    dist: xenial
80    env: PYTHON=3.6 CPP=17 GCC=7
81    name: Python 3.6, c++17, gcc 7
82    addons:
83      apt:
84        sources:
85          - deadsnakes
86          - ubuntu-toolchain-r-test
87        packages:
88          - g++-7
89          - python3.6-dev
90          - python3.6-venv
91  - os: linux
92    dist: xenial
93    env: PYTHON=3.6 CPP=17 CLANG=7
94    name: Python 3.6, c++17, Clang 7
95    addons:
96      apt:
97        sources:
98          - deadsnakes
99          - llvm-toolchain-xenial-7
100        packages:
101          - python3.6-dev
102          - python3.6-venv
103          - clang-7
104          - libclang-7-dev
105          - llvm-7-dev
106          - lld-7
107          - libc++-7-dev
108          - libc++abi-7-dev  # Why is this necessary???
109  - os: linux
110    dist: xenial
111    env: PYTHON=3.8 CPP=17 GCC=7
112    name: Python 3.8, c++17, gcc 7 (w/o numpy/scipy) # TODO: update build name when the numpy/scipy wheels become available
113    addons:
114      apt:
115        sources:
116          - deadsnakes
117          - ubuntu-toolchain-r-test
118        packages:
119          - g++-7
120          - python3.8-dev
121          - python3.8-venv
122    # Currently there is no numpy/scipy wheels available for python3.8
123    # TODO: remove next before_install, install and script clause when the wheels become available
124    before_install:
125      - pyenv global $(pyenv whence 2to3)  # activate all python versions
126      - PY_CMD=python3
127      - $PY_CMD -m pip install --user --upgrade pip wheel setuptools
128    install:
129      - $PY_CMD -m pip install --user --upgrade pytest
130    script:
131      - |
132        # Barebones build
133        cmake -DCMAKE_BUILD_TYPE=Debug -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DPYTHON_EXECUTABLE=$(which $PY_CMD) .
134        make pytest -j 2
135        make cpptest -j 2
136  - os: osx
137    name: Python 2.7, c++14, AppleClang 7.3, CMake test
138    osx_image: xcode7.3
139    env: PYTHON=2.7 CPP=14 CLANG CMAKE=1
140  - os: osx
141    name: Python 3.7, c++14, AppleClang 9, Debug build
142    osx_image: xcode9
143    env: PYTHON=3.7 CPP=14 CLANG DEBUG=1
144  # Test a PyPy 2.7 build
145  - os: linux
146    dist: trusty
147    env: PYPY=5.8 PYTHON=2.7 CPP=11 GCC=4.8
148    name: PyPy 5.8, Python 2.7, c++11, gcc 4.8
149    addons:
150      apt:
151        packages:
152          - libblas-dev
153          - liblapack-dev
154          - gfortran
155  # Build in 32-bit mode and tests against the CMake-installed version
156  - os: linux
157    dist: trusty
158    services: docker
159    env: DOCKER=i386/debian:stretch PYTHON=3.5 CPP=14 GCC=6 INSTALL=1
160    name: Python 3.5, c++14, gcc 6, 32-bit
161    script:
162      - |
163        # Consolidated 32-bit Docker Build + Install
164        set -ex
165        $SCRIPT_RUN_PREFIX sh -c "
166          set -ex
167          cmake ${CMAKE_EXTRA_ARGS} -DPYBIND11_INSTALL=1 -DPYBIND11_TEST=0 .
168          make install
169          cp -a tests /pybind11-tests
170          mkdir /build-tests && cd /build-tests
171          cmake ../pybind11-tests ${CMAKE_EXTRA_ARGS} -DPYBIND11_WERROR=ON
172          make pytest -j 2"
173        set +ex
174cache:
175  directories:
176  - $HOME/.local/bin
177  - $HOME/.local/lib
178  - $HOME/.local/include
179  - $HOME/Library/Python
180before_install:
181- |
182  # Configure build variables
183  set -ex
184  if [ "$TRAVIS_OS_NAME" = "linux" ]; then
185    if [ -n "$CLANG" ]; then
186      export CXX=clang++-$CLANG CC=clang-$CLANG
187      EXTRA_PACKAGES+=" clang-$CLANG llvm-$CLANG-dev"
188    else
189      if [ -z "$GCC" ]; then GCC=4.8
190      else EXTRA_PACKAGES+=" g++-$GCC"
191      fi
192      export CXX=g++-$GCC CC=gcc-$GCC
193    fi
194  elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
195    export CXX=clang++ CC=clang;
196  fi
197  if [ -n "$CPP" ]; then CPP=-std=c++$CPP; fi
198  if [ "${PYTHON:0:1}" = "3" ]; then PY=3; fi
199  if [ -n "$DEBUG" ]; then CMAKE_EXTRA_ARGS+=" -DCMAKE_BUILD_TYPE=Debug"; fi
200  set +ex
201- |
202  # Initialize environment
203  set -ex
204  if [ -n "$DOCKER" ]; then
205    docker pull $DOCKER
206
207    containerid=$(docker run --detach --tty \
208      --volume="$PWD":/pybind11 --workdir=/pybind11 \
209      --env="CC=$CC" --env="CXX=$CXX" --env="DEBIAN_FRONTEND=$DEBIAN_FRONTEND" \
210      --env=GCC_COLORS=\  \
211      $DOCKER)
212    SCRIPT_RUN_PREFIX="docker exec --tty $containerid"
213    $SCRIPT_RUN_PREFIX sh -c 'for s in 0 15; do sleep $s; apt-get update && apt-get -qy dist-upgrade && break; done'
214  else
215    if [ "$PYPY" = "5.8" ]; then
216      curl -fSL https://bitbucket.org/pypy/pypy/downloads/pypy2-v5.8.0-linux64.tar.bz2 | tar xj
217      PY_CMD=$(echo `pwd`/pypy2-v5.8.0-linux64/bin/pypy)
218      CMAKE_EXTRA_ARGS+=" -DPYTHON_EXECUTABLE:FILEPATH=$PY_CMD"
219    else
220      PY_CMD=python$PYTHON
221      if [ "$TRAVIS_OS_NAME" = "osx" ]; then
222        if [ "$PY" = "3" ]; then
223          brew update && brew upgrade python
224        else
225          curl -fsSL https://bootstrap.pypa.io/get-pip.py | $PY_CMD - --user
226        fi
227      fi
228    fi
229    if [ "$PY" = 3 ] || [ -n "$PYPY" ]; then
230      $PY_CMD -m ensurepip --user
231    fi
232    $PY_CMD --version
233    $PY_CMD -m pip install --user --upgrade pip wheel
234  fi
235  set +ex
236install:
237- |
238  # Install dependencies
239  set -ex
240  cmake --version
241  if [ -n "$DOCKER" ]; then
242    if [ -n "$DEBUG" ]; then
243      PY_DEBUG="python$PYTHON-dbg python$PY-scipy-dbg"
244      CMAKE_EXTRA_ARGS+=" -DPYTHON_EXECUTABLE=/usr/bin/python${PYTHON}dm"
245    fi
246    $SCRIPT_RUN_PREFIX sh -c "for s in 0 15; do sleep \$s; \
247      apt-get -qy --no-install-recommends install \
248        $PY_DEBUG python$PYTHON-dev python$PY-pytest python$PY-scipy \
249        libeigen3-dev libboost-dev cmake make ${EXTRA_PACKAGES} && break; done"
250  else
251
252    if [ "$CLANG" = "7" ]; then
253      export CXXFLAGS="-stdlib=libc++"
254    fi
255
256    export NPY_NUM_BUILD_JOBS=2
257    echo "Installing pytest, numpy, scipy..."
258    local PIP_CMD=""
259    if [ -n $PYPY ]; then
260      # For expediency, install only versions that are available on the extra index.
261      travis_wait 30 \
262        $PY_CMD -m pip install --user --upgrade --extra-index-url https://imaginary.ca/trusty-pypi \
263          pytest numpy==1.15.4 scipy==1.2.0
264    else
265      $PY_CMD -m pip install --user --upgrade pytest numpy scipy
266    fi
267    echo "done."
268
269    mkdir eigen
270    curl -fsSL https://bitbucket.org/eigen/eigen/get/3.3.4.tar.bz2 | \
271        tar --extract -j --directory=eigen --strip-components=1
272    export CMAKE_INCLUDE_PATH="${CMAKE_INCLUDE_PATH:+$CMAKE_INCLUDE_PATH:}$PWD/eigen"
273  fi
274  set +ex
275script:
276- |
277  # CMake Configuration
278  set -ex
279  $SCRIPT_RUN_PREFIX cmake ${CMAKE_EXTRA_ARGS} \
280    -DPYBIND11_PYTHON_VERSION=$PYTHON \
281    -DPYBIND11_CPP_STANDARD=$CPP \
282    -DPYBIND11_WERROR=${WERROR:-ON} \
283    -DDOWNLOAD_CATCH=${DOWNLOAD_CATCH:-ON} \
284    .
285  set +ex
286- |
287  # pytest
288  set -ex
289  $SCRIPT_RUN_PREFIX make pytest -j 2 VERBOSE=1
290  set +ex
291- |
292  # cpptest
293  set -ex
294  $SCRIPT_RUN_PREFIX make cpptest -j 2
295  set +ex
296- |
297  # CMake Build Interface
298  set -ex
299  if [ -n "$CMAKE" ]; then $SCRIPT_RUN_PREFIX make test_cmake_build; fi
300  set +ex
301after_failure: cat tests/test_cmake_build/*.log*
302after_script:
303- |
304  # Cleanup (Docker)
305  set -ex
306  if [ -n "$DOCKER" ]; then docker stop "$containerid"; docker rm "$containerid"; fi
307  set +ex
308