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).
11 dist: xenial # Necessary to run doxygen 1.8.15
12 name: Style, docs, and pip
15 - pyenv global $(pyenv whence 2to3) # activate all python versions
17 - $PY_CMD -m pip install --user --upgrade pip wheel setuptools
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"
23 - tools/check-style.sh
25 - $PY_CMD -m sphinx -W -b html docs docs/.build
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
34 cmake -DCMAKE_BUILD_TYPE=Debug -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -DPYTHON_EXECUTABLE=$(which $PY_CMD) .
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.
41 name: Python 2.7, c++11, gcc 4.8
42 env: PYTHON=2.7 CPP=11 GCC=4.8
50 name: Python 3.6, c++11, gcc 4.8
51 env: PYTHON=3.6 CPP=11 GCC=4.8
63 env: PYTHON=2.7 CPP=14 GCC=6 CMAKE=1
64 name: Python 2.7, c++14, gcc 4.8, CMake test
68 - ubuntu-toolchain-r-test
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.
77 env: DOCKER=debian:stretch PYTHON=3.5 CPP=14 GCC=6 DEBUG=1
80 env: PYTHON=3.6 CPP=17 GCC=7
81 name: Python 3.6, c++17, gcc 7
86 - ubuntu-toolchain-r-test
93 env: PYTHON=3.6 CPP=17 CLANG=7
94 name: Python 3.6, c++17, Clang 7
99 - llvm-toolchain-xenial-7
108 - libc++abi-7-dev # Why is this necessary???
110 name: Python 2.7, c++14, AppleClang 7.3, CMake test
112 env: PYTHON=2.7 CPP=14 CLANG CMAKE=1
114 name: Python 3.7, c++14, AppleClang 9, Debug build
116 env: PYTHON=3.7 CPP=14 CLANG DEBUG=1
117 # Test a PyPy 2.7 build
120 env: PYPY=5.8 PYTHON=2.7 CPP=11 GCC=4.8
121 name: PyPy 5.8, Python 2.7, c++11, gcc 4.8
128 # Build in 32-bit mode and tests against the CMake-installed version
132 env: DOCKER=i386/debian:stretch PYTHON=3.5 CPP=14 GCC=6 INSTALL=1
133 name: Python 3.4, c++14, gcc 6, 32-bit
136 # Consolidated 32-bit Docker Build + Install
138 $SCRIPT_RUN_PREFIX sh -c "
140 cmake ${CMAKE_EXTRA_ARGS} -DPYBIND11_INSTALL=1 -DPYBIND11_TEST=0 .
142 cp -a tests /pybind11-tests
143 mkdir /build-tests && cd /build-tests
144 cmake ../pybind11-tests ${CMAKE_EXTRA_ARGS} -DPYBIND11_WERROR=ON
151 - $HOME/.local/include
152 - $HOME/Library/Python
155 # Configure build variables
157 if [ "$TRAVIS_OS_NAME" = "linux" ]; then
158 if [ -n "$CLANG" ]; then
159 export CXX=clang++-$CLANG CC=clang-$CLANG
160 EXTRA_PACKAGES+=" clang-$CLANG llvm-$CLANG-dev"
162 if [ -z "$GCC" ]; then GCC=4.8
163 else EXTRA_PACKAGES+=" g++-$GCC"
165 export CXX=g++-$GCC CC=gcc-$GCC
167 elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
168 export CXX=clang++ CC=clang;
170 if [ -n "$CPP" ]; then CPP=-std=c++$CPP; fi
171 if [ "${PYTHON:0:1}" = "3" ]; then PY=3; fi
172 if [ -n "$DEBUG" ]; then CMAKE_EXTRA_ARGS+=" -DCMAKE_BUILD_TYPE=Debug"; fi
175 # Initialize environment
177 if [ -n "$DOCKER" ]; then
180 containerid=$(docker run --detach --tty \
181 --volume="$PWD":/pybind11 --workdir=/pybind11 \
182 --env="CC=$CC" --env="CXX=$CXX" --env="DEBIAN_FRONTEND=$DEBIAN_FRONTEND" \
185 SCRIPT_RUN_PREFIX="docker exec --tty $containerid"
186 $SCRIPT_RUN_PREFIX sh -c 'for s in 0 15; do sleep $s; apt-get update && apt-get -qy dist-upgrade && break; done'
188 if [ "$PYPY" = "5.8" ]; then
189 curl -fSL https://bitbucket.org/pypy/pypy/downloads/pypy2-v5.8.0-linux64.tar.bz2 | tar xj
190 PY_CMD=$(echo `pwd`/pypy2-v5.8.0-linux64/bin/pypy)
191 CMAKE_EXTRA_ARGS+=" -DPYTHON_EXECUTABLE:FILEPATH=$PY_CMD"
194 if [ "$TRAVIS_OS_NAME" = "osx" ]; then
195 if [ "$PY" = "3" ]; then
196 brew update && brew upgrade python
198 curl -fsSL https://bootstrap.pypa.io/get-pip.py | $PY_CMD - --user
202 if [ "$PY" = 3 ] || [ -n "$PYPY" ]; then
203 $PY_CMD -m ensurepip --user
206 $PY_CMD -m pip install --user --upgrade pip wheel
211 # Install dependencies
214 if [ -n "$DOCKER" ]; then
215 if [ -n "$DEBUG" ]; then
216 PY_DEBUG="python$PYTHON-dbg python$PY-scipy-dbg"
217 CMAKE_EXTRA_ARGS+=" -DPYTHON_EXECUTABLE=/usr/bin/python${PYTHON}dm"
219 $SCRIPT_RUN_PREFIX sh -c "for s in 0 15; do sleep \$s; \
220 apt-get -qy --no-install-recommends install \
221 $PY_DEBUG python$PYTHON-dev python$PY-pytest python$PY-scipy \
222 libeigen3-dev libboost-dev cmake make ${EXTRA_PACKAGES} && break; done"
225 if [ "$CLANG" = "7" ]; then
226 export CXXFLAGS="-stdlib=libc++"
229 export NPY_NUM_BUILD_JOBS=2
230 echo "Installing pytest, numpy, scipy..."
232 if [ -n $PYPY ]; then
233 # For expediency, install only versions that are available on the extra index.
235 $PY_CMD -m pip install --user --upgrade --extra-index-url https://imaginary.ca/trusty-pypi \
236 pytest numpy==1.15.4 scipy==1.2.0
238 $PY_CMD -m pip install --user --upgrade pytest numpy scipy
243 curl -fsSL https://bitbucket.org/eigen/eigen/get/3.3.4.tar.bz2 | \
244 tar --extract -j --directory=eigen --strip-components=1
245 export CMAKE_INCLUDE_PATH="${CMAKE_INCLUDE_PATH:+$CMAKE_INCLUDE_PATH:}$PWD/eigen"
250 # CMake Configuration
252 $SCRIPT_RUN_PREFIX cmake ${CMAKE_EXTRA_ARGS} \
253 -DPYBIND11_PYTHON_VERSION=$PYTHON \
254 -DPYBIND11_CPP_STANDARD=$CPP \
255 -DPYBIND11_WERROR=${WERROR:-ON} \
256 -DDOWNLOAD_CATCH=${DOWNLOAD_CATCH:-ON} \
262 $SCRIPT_RUN_PREFIX make pytest -j 2 VERBOSE=1
267 $SCRIPT_RUN_PREFIX make cpptest -j 2
270 # CMake Build Interface
272 if [ -n "$CMAKE" ]; then $SCRIPT_RUN_PREFIX make test_cmake_build; fi
274 after_failure: cat tests/test_cmake_build/*.log*
279 if [ -n "$DOCKER" ]; then docker stop "$containerid"; docker rm "$containerid"; fi