You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
7.1 KiB

3 months ago
  1. language: cpp
  2. sudo: false
  3. matrix:
  4. include:
  5. - os: linux
  6. env: PYTHON=2.7 CPP=11 GCC=4.8
  7. addons:
  8. apt:
  9. sources: [ubuntu-toolchain-r-test, kubuntu-backports]
  10. packages: [g++-4.8, cmake]
  11. - os: linux
  12. env: PYTHON=3.5 CPP=11 GCC=4.8
  13. addons:
  14. apt:
  15. sources: [ubuntu-toolchain-r-test, kubuntu-backports, deadsnakes]
  16. packages: [g++-4.8, cmake, python3.5-dev]
  17. - sudo: true
  18. services: docker
  19. env: PYTHON=2.7 CPP=14 GCC=6
  20. - sudo: true
  21. services: docker
  22. env: PYTHON=3.5 CPP=14 GCC=6 DEBUG=1
  23. - sudo: true
  24. services: docker
  25. env: PYTHON=3.5 CPP=17 GCC=7
  26. - sudo: true
  27. services: docker
  28. env: PYTHON=3.5 CPP=17 CLANG=4.0
  29. - os: osx
  30. osx_image: xcode7.3
  31. env: PYTHON=2.7 CPP=14 CLANG
  32. - os: osx
  33. osx_image: xcode7.3
  34. env: PYTHON=3.6 CPP=14 CLANG
  35. # Test a PyPy 2.7 build
  36. - os: linux
  37. dist: trusty
  38. env: PYPY=5.7 PYTHON=2.7 CPP=11 GCC=4.8
  39. addons:
  40. apt:
  41. packages: [g++-4.8, cmake]
  42. - sudo: true
  43. services: docker
  44. env: ARCH=i386 PYTHON=3.5 CPP=14 GCC=6
  45. # This next one does a make install *before* testing, then builds the tests against the installed version:
  46. - sudo: true
  47. services: docker
  48. env: PYTHON=3.5 CPP=14 CLANG=3.9 INSTALL=1
  49. script:
  50. - |
  51. $SCRIPT_RUN_PREFIX sh -c "set -e
  52. cmake ${CMAKE_EXTRA_ARGS} -DPYBIND11_INSTALL=1 -DPYBIND11_TEST=0
  53. make install
  54. cp -a tests /pybind11-tests
  55. mkdir /build-tests && cd /build-tests
  56. cmake ../pybind11-tests ${CMAKE_EXTRA_ARGS} -DPYBIND11_WERROR=ON
  57. make pytest -j 2"
  58. # A barebones build makes sure everything still works without optional deps (numpy/scipy/eigen)
  59. # and also tests the automatic discovery functions in CMake (Python version, C++ standard).
  60. - os: linux
  61. env: BAREBONES
  62. addons:
  63. apt:
  64. sources: [ubuntu-toolchain-r-test, kubuntu-backports]
  65. packages: [g++-4.8, cmake]
  66. install: pip install pytest
  67. # Documentation build:
  68. - os: linux
  69. language: docs
  70. env: DOCS STYLE LINT
  71. install:
  72. - pip install --upgrade sphinx sphinx_rtd_theme flake8 pep8-naming
  73. - |
  74. curl -fsSL ftp://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.12.linux.bin.tar.gz | tar xz
  75. export PATH="$PWD/doxygen-1.8.12/bin:$PATH"
  76. pip install https://github.com/michaeljones/breathe/archive/master.zip
  77. script:
  78. - make -C docs html SPHINX_OPTIONS=-W
  79. - tools/check-style.sh
  80. - flake8
  81. allow_failures:
  82. - env: PYTHON=3.5 CPP=17 GCC=7
  83. - env: PYTHON=3.5 CPP=17 CLANG=4.0
  84. cache:
  85. directories:
  86. - $HOME/.cache/pip
  87. - $HOME/Library/Caches/pip
  88. before_install:
  89. - |
  90. # Configure build variables
  91. if [ "$TRAVIS_OS_NAME" = "linux" ]; then
  92. if [ -n "$CLANG" ]; then
  93. export CXX=clang++-$CLANG CC=clang-$CLANG COMPILER_PACKAGES="clang-$CLANG llvm-$CLANG-dev"
  94. if [ "$CLANG" = "4.0" ]; then export CXXFLAGS="-stdlib=libc++"; fi
  95. else
  96. if [ -z "$GCC" ]; then export GCC=4.8
  97. else export COMPILER_PACKAGES=g++-$GCC
  98. fi
  99. export CXX=g++-$GCC CC=gcc-$GCC
  100. fi
  101. if [ "$CLANG" = "4.0" ]; then export DOCKER=debian:sid
  102. elif [ "$GCC" = "6" ] || [ -n "$CLANG" ]; then export DOCKER=${ARCH:+$ARCH/}debian:testing
  103. elif [ "$GCC" = "7" ]; then export DOCKER=debian:experimental APT_GET_EXTRA="-t experimental"
  104. fi
  105. elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
  106. export CXX=clang++ CC=clang;
  107. fi
  108. if [ -n "$CPP" ]; then export CPP=-std=c++$CPP; fi
  109. if [ "${PYTHON:0:1}" = "3" ]; then export PY=3; fi
  110. if [ "$PYPY" = "5.7" ]; then
  111. curl -fSL https://bitbucket.org/pypy/pypy/downloads/pypy2-v5.7.0-linux64.tar.bz2 | tar -xj
  112. export PYPY_BINARY=$(echo `pwd`/pypy2-v5.7.0-linux64/bin/pypy)
  113. export CMAKE_EXTRA_ARGS="-DPYTHON_EXECUTABLE:FILEPATH=$PYPY_BINARY"
  114. fi
  115. if [ -n "$DEBUG" ]; then export CMAKE_EXTRA_ARGS="-DCMAKE_BUILD_TYPE=Debug"; fi
  116. - |
  117. # Initialize environment
  118. if [ -n "$PYPY" ]; then
  119. $PYPY_BINARY -m ensurepip
  120. $PYPY_BINARY -m pip install pytest
  121. elif [ -n "$DOCKER" ]; then
  122. docker pull $DOCKER
  123. # Disable LTO with gcc until gcc 79296 is fixed:
  124. if [ -n "$GCC" ]; then export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DPYBIND11_LTO_CXX_FLAGS="; fi
  125. export containerid=$(docker run --detach --tty \
  126. --volume="$PWD":/pybind11 --workdir=/pybind11 \
  127. --env="CXXFLAGS=$CXXFLAGS" \
  128. --env="CC=$CC" --env="CXX=$CXX" --env="DEBIAN_FRONTEND=$DEBIAN_FRONTEND" \
  129. --env=GCC_COLORS=\ \
  130. $DOCKER)
  131. export SCRIPT_RUN_PREFIX="docker exec --tty $containerid"
  132. $SCRIPT_RUN_PREFIX sh -c 'for s in 0 15; do sleep $s; apt-get update && apt-get -qy dist-upgrade && break; done'
  133. # gcc-7 currently generates warnings; some are upstream bugs, so just turn off -Werror for now
  134. if [ "$GCC" = "7" ]; then WERROR=off; fi
  135. else
  136. if [ "$TRAVIS_OS_NAME" = "linux" ]; then
  137. pip install --user --upgrade pip virtualenv
  138. virtualenv -p python$PYTHON venv
  139. elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
  140. if [ "$PY" = "3" ]; then
  141. brew update; brew install python$PY;
  142. else
  143. curl -fsSL -O https://bootstrap.pypa.io/get-pip.py
  144. sudo -H python get-pip.py
  145. fi
  146. pip$PY install --user --upgrade pip virtualenv
  147. python$PY -m virtualenv venv
  148. fi
  149. source venv/bin/activate
  150. fi
  151. install:
  152. - |
  153. # Install dependencies
  154. if [ -n "$DOCKER" ]; then
  155. if [ -n "$DEBUG" ]; then
  156. PY_DEBUG="python$PY-dbg python$PY-scipy-dbg"
  157. export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DPYTHON_EXECUTABLE=/usr/bin/python${PYTHON}dm"
  158. fi
  159. $SCRIPT_RUN_PREFIX sh -c "for s in 0 15; do sleep \$s; \
  160. apt-get -qy --no-install-recommends $APT_GET_EXTRA install \
  161. $PY_DEBUG python$PY-dev python$PY-pytest python$PY-scipy \
  162. libeigen3-dev cmake make ${COMPILER_PACKAGES} && break; done"
  163. if [ "$CLANG" = "4.0" ]; then
  164. # Neither debian nor llvm provide a libc++ deb; luckily it's fairly quick
  165. # to build and install, so do it ourselves:
  166. git clone --depth=1 https://github.com/llvm-mirror/llvm.git llvm-source
  167. git clone https://github.com/llvm-mirror/libcxx.git llvm-source/projects/libcxx -b release_40
  168. git clone https://github.com/llvm-mirror/libcxxabi.git llvm-source/projects/libcxxabi -b release_40
  169. $SCRIPT_RUN_PREFIX sh -c "mkdir llvm-build && cd llvm-build && \
  170. CXXFLAGS= cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ../llvm-source && \
  171. make -j2 install-cxxabi install-cxx && \
  172. cp -a include/c++/v1/*cxxabi*.h /usr/include/c++/v1"
  173. if [ "$CPP" = "-std=c++17" ]; then export CPP="-std=c++1z"; fi
  174. fi
  175. elif [ -z "$PYPY" ]; then
  176. pip install numpy scipy pytest
  177. wget -q -O eigen.tar.gz https://bitbucket.org/eigen/eigen/get/3.3.0.tar.gz
  178. tar xzf eigen.tar.gz
  179. export CMAKE_EXTRA_ARGS="${CMAKE_EXTRA_ARGS} -DCMAKE_INCLUDE_PATH=$PWD/eigen-eigen-26667be4f70b"
  180. fi
  181. script:
  182. - $SCRIPT_RUN_PREFIX cmake ${CMAKE_EXTRA_ARGS}
  183. -DPYBIND11_PYTHON_VERSION=$PYTHON
  184. -DPYBIND11_CPP_STANDARD=$CPP
  185. -DPYBIND11_WERROR=${WERROR:-ON}
  186. - $SCRIPT_RUN_PREFIX make pytest -j 2
  187. - $SCRIPT_RUN_PREFIX make test_cmake_build
  188. after_failure: cat tests/test_cmake_build/*.log
  189. after_script:
  190. - if [ -n "$DOCKER" ]; then docker stop "$containerid"; docker rm "$containerid"; fi