Commit 90e56b2b authored by PyBind11 Upstream's avatar PyBind11 Upstream Committed by Atkins, Charles Vernon
Browse files

pybind11 2019-10-15 (80d45248)

Code extracted from:

    https://github.com/pybind/pybind11.git

at commit 80d452484c5409444b0ec19383faa84bb7a4d351 (v2.4.3).

Upstream Shortlog
-----------------

Ahuva Kroizer (1):
      8f5b7fce FAQ addition (#1606)

Alexander Gagarin (2):
      0071a3fe Fix async Python functors invoking from multiple C++ threads (#1587) (#1595)
      b3bf248e Fix casting of time points with non-system-clock duration with VS (#1748)

Allan Leal (1):
      e76dff77 Fix for Issue #1258 (#1298)

Andre Schmeißer (1):
      19189b4c Make `overload_cast_impl` available in C++11 mode. (#1581)

Ansgar Burchardt (1):
      a22dd2d1 correct stride in matrix example and test

Antony Lee (6):
      a303c6fc Remove spurious quote in error message. (#1202)
      0826b3c1 Add spaces around "=" in signature repr.
      8fbb5594 Clarify error_already_set documentation.
      55dc1319 Clarify docs for functions taking bytes and not str.
      58e551cc Properly report exceptions thrown during module initialization.
      baf6b990 Silence GCC8's -Wcast-function-type. (#1396)

Axel Huebl (9):
      4b84bad7 Fix Travis GCC 7 Python 3.6.6 (#1436)
      97b20e53 CMake: Remember Python Version (#1434)
      3a94561c Debug Builds: -DPy_DEBUG (#1438)
      435dbdd1 add_module: allow include as SYSTEM (#1416)
      9424d5d2 type_record: Uninit Member (#1658)
      1c627c9e pybind11_getbuffer: useless safe nullptr check (#1664)
      a2cdd0b9 dict_readonly: member init (#1661)
      000aabb2 Test: Numpy Scalar Creation (#1530)
      38f408fc value_and_holder: uninit members (#1660)

Baljak (1):
      81da9888 Fix Intel C++ compiler warning on Windows (#1608)

Blake Thompson (1):
      30c03523 Added __contains__ to stl bindings for maps (#1767)

Boris Dalstein (2):
      b30734ee Fix typo in doc: build-in -> built-in
      96be2c15 Fix version mismatch typos in .travis.yml (#1948)

Boris Staletic (4):
      289e5d9c Implement an enum_ property "name"
      f4b4e2e9 Use new Doxygen archive URL - fixes Travis
      0ca6867e Avoid Visual Studio 2017 15.9.4 ICE
      b3f0b4de new sphinx (#1786)

Borja Zarco (2):
      e2b884c3 Use `PyGILState_GetThisThreadState` when using gil_scoped_acquire. (#1211)
      b2fdfd12 Avoid use of lambda to work around a clang bug. (#1883)

Bruce Merry (2):
      1e6172d4 Fix some minor mistakes in comments on struct instance
      3b265787 Document using atexit for module destructors on PyPy (#1169)

Chris Rusby (1):
      22859bb8 Support more natural syntax for vector extend

Christoph Kahl (1):
      640b8fe6 fix #1406 add mingw compatibility (#1851)

Dan (10):
      a175b21e Avoid decoding already-decoded strings from cindex.
      4612db54 Try to autodetect the location of the clang standard libraries.
      b46bb64d Allow user to override default values of -x and -std=.
      a33212df Wrap the main functionality of mkdoc in a function.
      ede328a7 Allow writing output to file instead of stdout.
      a163f881 Delete partially-written file in the event of an error.
      590e7ace Avoid storing global state.
      2c8c5c4e Split into seperate functions for easier invocation from python.
      e0b8bbbc Use a file-local constant for non-prefixing nodes.
      41f29ccd Parse command-line args in a separate function.

Darius Arnold (1):
      09330b94 Fix typos in documentation (#1635)

David Caron (1):
      307ea6b7 Typo

Davis E. King (1):
      9343e68b Fix cmake scripts so projects using CUDA .cu files build correctly. (#1441)

Dean Moldovan (3):
      c10ac6cf Make it possible to generate constexpr signatures in C++11 mode
      56613945 Use semi-constexpr signatures on MSVC
      0aef6422 Simplify function signature annotation and parsing

Dennis Luxen (1):
      221fb1e1 Untangle cast logic to not implicitly require castability (#1442)

Dmitry (1):
      8f5a8ab4 Don't strip debug symbols in RelWithDebInfo mode (#1892)

Elliott Sales de Andrade (1):
      5e7591c6 Update PyPI URLs.

Eric Cousineau (2):
      e9ca89f4 numpy: Add test for explicit dtype checks. At present, int64 + uint64 do not exactly match dtype(...).num
      4a3464fd numpy: Provide concrete size aliases

Francesco Biscani (1):
      ba33b2fc Add -Wdeprecated to test suite and fix associated warnings (#1191)

François Becker (1):
      ce9d6e2c Fixed typo in classes.rst (#1388)

Guilhem Saurel (2):
      e7ef34f2 compatibility with pytest 4.0, fix #1670
      43a39bc7 ignore numpy.ufunc size warnings

Henry Schreiner (10):
      04b41f03 Upgrading to Xcode 9 & fix OSX/Py3 build failure
      cf0d0f9d Matching Python 2 int behavior on Python 2 (#1186)
      6c62d279 Fix for conda failures on Windows
      ffd56ebe Fix pip issues on AppVeyor CI (#1369)
      3789b4f9 Update C++ macros for C++17 and MSVC Z mode (#1347)
      0f404a5d Allow recursive checkout without https (#1563)
      ae951ca0 CI fixes (#1744)
      73b840dc Fix for issue in latest conda (#1757)
      9bb33131 Fixing warnings about conversions in GCC 7+ (#1753)
      047ce8c4 Fix iostream when used with nogil (#1368)

Ian Bell (1):
      502ffe50 Add docs and tests for unary op on class (#1814)

Igor Socec (1):
      a301c5ad Dtype field ordering for NumPy 1.14 (#1837)

Ivan Smirnov (1):
      d1db2ccf Make register_dtype() accept any field containers (#1225)

Ivor Wanders (1):
      2b045757 Improve documentation related to inheritance. (#1676)

Jamie Snape (1):
      a0b8f70d Ensure PythonLibsNew_FOUND is set in FindPythonLibsNew module (#1373)

Jason Rhinelander (31):
      c6a57c10 Fix dtype string leak
      d2757d04 Remove superfluous "requires_numpy"
      64a99b92 Specify minimum needed cmake version in test suite
      1b08df58 Fix `char &` arguments being non-bindable
      7672292e Add informative compilation failure for method_adaptor failures
      6a81dbbb Fix 2D Nx1/1xN inputs to eigen dense vector args
      a582d6c7 Build /permissive- under VS2017
      835fa9bc Miscellaneous travis-ci updates/fixes
      32ef69ac Qualify `cast_op_type` to help ICC
      5c7a290d Fix new flake8 E741 error from using `l` variable
      71178922 __qualname__ and nested class naming fixes (#1171)
      086d53e8 Clean up eigen download code (and bump to 3.3.4)
      3be401f2 Silence new MSVC C++17 deprecation warnings
      48e1f9aa Fix premature destruction of args/kwargs arguments
      367d723a Simplify arg copying
      b48d4a01 Added py::args ref counting tests
      88efb251 Fixes for numpy 1.14.0 compatibility
      507da418 Use a named rather than anon struct in instance
      326deef2 Fix segfault when reloading interpreter with external modules (#1092)
      adbc8111 Use stricter brace initialization
      657a51e8 Remove unnecessary `detail::`
      add56ccd MSVC workaround for broken `using detail::_` warning
      431fc0e1 Fix numpy dtypes test on big-endian architectures
      1ddfacba Fix for Python3 via brew
      e88656ab Improve macro type handling for types with commas
      9f41c8ea Fix class name in overload failure message
      6d0b4708 Reimplement version check and combine init macros
      6862cb9b Add workaround for clang 3.3/3.4
      e763f046 Base class destructor should be virtual
      f7bc18f5 Fix compatibility with catch v2
      177713fa Fix gcc-8 compilation warning

Jeff VanOss (3):
      05d379a9 fix return from std::map bindings to __delitem__ (#1229)
      01839dce remove duplicate feature from list (#1476)
      77ef03d5 compile time check that  properties have no py:arg values (#1524)

Jeffrey Quesnelle (1):
      f93cd0aa PYBIND11_TLS_REPLACE_VALUE should use macro argument value in Python 3.7+ (#1683)

Jeremy Maitin-Shepard (1):
      a3f4a0e8 Add support for __await__, __aiter__, and __anext__ protocols (#1842)

Josh Kelley (1):
      741576dd Update documentation for initialize_interpreter (#1584)

Justin Bassett (1):
      2cbafb05 fix detail::pythonbuf::overflow()'s return value to return not_eof(c) (#1479)

Jörg Kreuzberger (1):
      69dc380c #1208 Handle forced unwind exception (e.g. during pthread termination)

Karl Haubenwallner (1):
      e9d6e879 Added a debug flag to the PYBIND11_INTERNALS_VERSION (#1549)

Khachajantc Michael (1):
      e3cb2a67 Use std::addressof to obtain holder address instead of operator&

Krzysztof Fornalczyk (1):
      5c8746ff check for already existing enum value added; added test (#1453)

Lori A. Burns (3):
      bdbe8d0b Enforces intel icpc >= 2017, fixes #1121 (#1363)
      868d94fc Apply c++ standard flag only to files of CXX language. (#1678)
      f6c4c104 restores __invert__ to arithmetic-enabled enum, fixes #1907 (#1909)

Maciek Starzyk (1):
      9b028562 Update PyPI URLs

Manuel Schneider (1):
      492da592 another typo (#1675)

Marc Schlaich (1):
      ab003dbd Correct VS version in FAQ

Matthias Geier (1):
      7bb1da96 fix copy-paste error: non-const -> const

Michael Goulding (1):
      77374a7e VS 15.8.0 Preview 4.0 has a bug with alias templates (#1462)

Michał Wawrzyniec Urbańczyk (1):
      978d439e Add PYBIND11_ prefix to the THROW macro to prevent name collisions. (#1578)

Naotoshi Seo (1):
      5ef1af13 Fix SEGV to create empty shaped numpy array (#1371)

Nathan (1):
      9b3fb053 Allow Windows.h min/max to coexist with pybind11 (#1847)

Omar Awile (2):
      ac6cb91a Fixed small typo (#1633)
      95f750a8 Add optional buffer size to pythonbuf::d_buffer constructor (#1687)

Patrik Huber (1):
      41a4fd8a Fix missing word typo

Pauli Virtanen (1):
      c9d32a81 numpy: fix refcount leak to dtype singleton (#1860)

Roland Dreier (2):
      7a24bcf1 Fix malformed reST (#1802)
      1aa8dd17 Fix assertion failure for unions (#1685) (#1709)

Rune Paamand (2):
      73634b6d Update iostream.h: Changed a local varname 'self' to 'self_' (#1535)
      06d021b6 Issue #1532: Incompatible config options, /MP vs /Gm for MSVC in DEBUG (#1533)

Ryota Suzuki (1):
      1377fbf7 Fix unintentional escaping of character on Windows (#1574) (#1575)

Samuel Debionne (2):
      87fa6a43 Detect whether we are running in a Conda environment and adjust get_include() (#1877)
      6ca312b3 Avoid infinite recursion in is_copy_constructible (#1910)

Saran Tunyasuvunakool (2):
      b60fd233 Make sure `detail::get_internals` acquires the GIL before making Python calls. (#1836)
      bdf1a2cc In internals.h, only look at _DEBUG when compiling with MSVC. (#1855)

Semen Yesylevskyy (1):
      ef13fb2e Info about inconsistent detection of Python version between pybind11 … (#1093)

Sergei Izmailov (3):
      979d75de doc: Add note about casting from `None` to `T*` (#1760)
      09f08294  Avoid conversion to `int_` rhs argument of enum eq/ne (#1912)
      6cb584e9 Adapt to python3.8 C API change (#1950)

Sergei Lebedev (2):
      08b0bda4 Added set::contains and generalized dict::contains (#1884)
      046267c6 Added .empty() to all collection types (#1887)

Stephen Larew (1):
      5b4751af Add const to buffer:request() (#1890)

Steven Johnson (1):
      4ddf7c40 Add missing includes for better Bazel compatibility (#1255)

Tarcísio Fischer (1):
      54eb8193 Fix scoped enums comparison for equal/not equal cases (#1339) (#1571)

Ted Drain (1):
      0a0758ce Added write only property functions for issue #1142 (#1144)

Thomas Hrabe (1):
      534b756c Minor documentation clarification in numpy.rst (#1356)

Thomas Peters (1):
      dffe869d quiet clang warning by adding default move ctor (#1821)

Tom de Geus (1):
      a7ff616d Simplified example allowing more robust usage, fixed minor spelling issues

Tomas Babej (1):
      01fada76 Minor typo

Toru Niina (1):
      74d335a5 Replace a usage of C++14 language features with C++11 code (#1833)

Trevor Laughlin (1):
      63c2a972 Enable unique_ptr holder with mixed Deleters between base and derived types (#1353)

Unknown (1):
      0b3f44eb Trivial typos

Vladimír Vondruš (2):
      5b0ea77c Fix -Wmissing-prototypes warning on Clang. (#1863)
      04c8f4b5 Expose BufferError among other pybind11 exceptions. (#1852)

Wenzel Jakob (51):
      f94d7598 updated changelog for v2.2.1 release
      6d19036c support docstrings in enum::value() (#1160)
      e7d304fb added citation reference (fixes #767) (#1189)
      15e0e445 Moved section on licensing of contributions (fixes #1109) (#1188)
      ff6bd092 Fix pybind11 interoperability with Clang trunk (#1269)
      2d0507db added v2.2.2 changelog
      060936fe Detect pybind11 header path without depending on pip internals (fixes #1174) (#1190)
      ed670055 Minor fix for MSVC warning CS4459 (#1374)
      f5f66189 updated changelog for v2.2.3
      cbd16a82 stl.h: propagate return value policies to type-specific casters (#1455)
      d4b37a28 added py::ellipsis() method for slicing of multidimensional NumPy arrays
      885b5b90 Eigen test suite: don't create a np.matrix
      e0f3a766 Fixed flake8 error in test_iostream.py
      44e39e0d fix regression reported by @cyfdecyf in #1454 (#1517)
      35c82c72 changelog for version 2.2.4 & features targeted for 2.3.0
      06710020 object_api: support the number protocol
      b4b22924 relax operator[] for tuples, lists, and sequences
      f4245181 enum_: move most functionality to a non-template implementation
      c8e9f3cc quench __setstate__ warnings (fixes #1522)
      c9b8933e flake8 fix
      9f73060c std::array<> caster: support arbitrary sequences (#1602)
      adc2cdd5 fixed regression in STL type caster RVPs (fixes #1561) (#1603)
      e2eca4f8 Support C++17 aligned new statement (#1582)
      cea42467 fix py::cast<void *> (#1605)
      64205140 added std::deque to overview.rst
      d1f64fa9 AppVeyor: quench pip deprecation warnings for v2.7
      ccbe68b0 added binding delattr() -> PyObject_DelAttr analogous to hasattr()
      25abf7ef flake8 fixes
      e11e71d8 Make compiler flags for -Werror specific to GNU, Clang, or Intel
      51ca6b08 Update docs on std::out_of_range exception mapping (#1254)
      cf36e3d9 updated changelog
      64f2a5f8 begin work on v2.3.1
      ed39c504 README.md: added several folks who've made repeated contributions
      a1b71df1 fix issue #1804 (warning about redefined macros)
      8b90b1da error_already_set: acquire GIL one line earlier (fixes #1779)
      9fd47121 fix test suite (pytest changes in ExceptionInfo class)
      b2c4ff60 renamed local gil_scoped_acquire to gil_scoped_acquire_local to avoid ambiguity
      c9f5a464 pybind11 internals: separate different compilers
      00a0aa99 v2.4.0 release
      e825205a begin working on v2.4.1
      21d0eb46 Fix Python 3.8 test regression
      5fd187eb minor changelog cleanup
      31680e6f Implicit conversion from enum to int for Python 3.8 (fix by @sizmailov)
      e44fcc3c v2.4.1 release
      82cf7935 begin working on next version
      f3109d84 future-proof Python version check from commit 31680e6 (@lgritz)
      7f5dad7d Remove usage of C++14 constructs (fixes #1929)
      7ec2ddfc v2.4.2 release
      2abd7e1e updated release.rst to remove parts that are now automated
      34c2281e begin working on next version
      80d45248 v2.4.3 release

Yannick Jadoul (4):
      b4719a60 Switching deprecated Thread Local Storage (TLS) usage in Python 3.7 to Thread Specific Storage (TSS) (#1454)
      085a2943 Increasing timeout in test_gil_scoped.py to get AppVeyor to succeed
      97784dad [BUGFIX] Fixing pybind11::error_already_set.matches to also work with exception subclasses (#1715)
      d23c821b Make static member functions, added with `def_static`, `staticmethod` descriptor instances (#1732)

Zach DeVito (1):
      03874e37 Fix leak in var arg handling

ali-beep (1):
      5ef13eb6 Add negative indexing support to stl_bind. (#1882)

cdyson37 (1):
      111b25b2 Mention flake8 and check-style.sh in CONTRIBUTING (#1567)

kingofpayne (1):
      12e8774b Added support for list insertion. (#1888)

luz.paz (2):
      28cb6764 misc. typos
      13c08072 Typo

luzpaz (2):
      4b874616 Misc. typos (#1384)
      21bf16f5 misc. comment typo (#1629)

martinRenou (1):
      35045eee Add getters for exception type, value and traceback (#1641)

nstelzen (1):
      c2514340 Added note in documentation regarding make install (#1801)

oremanj (2):
      fd9bc8f5 Add basic support for tag-based static polymorphism (#1326)
      e7761e33 Fix potential crash when calling an overloaded function (#1327)

phil-zxx (1):
      c6b699d9 Added ability to convert from datetime.date to system_clock::time_point (#1848)

sizmailov (1):
      21c3911b add signed overload for `py::slice::compute`

voxmea (1):
      17983e74 Adds type_caster support for std::deque. (#1609)
parent 6fcb4e8c
version: 1.0.{build}
image:
- Visual Studio 2017
- Visual Studio 2015
test: off
build:
parallel: true
platform:
- x64
- x86
environment:
matrix:
- PYTHON: 36
CPP: 14
CONFIG: Debug
- PYTHON: 27
CPP: 14
CONFIG: Debug
- CONDA: 36
CPP: latest
CONFIG: Release
matrix:
exclude:
- image: Visual Studio 2015
platform: x86
- image: Visual Studio 2015
CPP: latest
- image: Visual Studio 2017
CPP: latest
platform: x86
install:
- ps: |
if ($env:PLATFORM -eq "x64") { $env:CMAKE_ARCH = "x64" }
if ($env:APPVEYOR_JOB_NAME -like "*Visual Studio 2017*") {
$env:CMAKE_GENERATOR = "Visual Studio 15 2017"
$env:CMAKE_INCLUDE_PATH = "C:\Libraries\boost_1_64_0"
$env:CXXFLAGS = "-permissive-"
} else {
$env:CMAKE_GENERATOR = "Visual Studio 14 2015"
}
if ($env:PYTHON) {
if ($env:PLATFORM -eq "x64") { $env:PYTHON = "$env:PYTHON-x64" }
$env:PATH = "C:\Python$env:PYTHON\;C:\Python$env:PYTHON\Scripts\;$env:PATH"
python -m pip install --upgrade pip wheel
python -m pip install pytest numpy --no-warn-script-location
} elseif ($env:CONDA) {
if ($env:CONDA -eq "27") { $env:CONDA = "" }
if ($env:PLATFORM -eq "x64") { $env:CONDA = "$env:CONDA-x64" }
$env:PATH = "C:\Miniconda$env:CONDA\;C:\Miniconda$env:CONDA\Scripts\;$env:PATH"
$env:PYTHONHOME = "C:\Miniconda$env:CONDA"
conda install -y -q pytest numpy scipy
}
- ps: |
Start-FileDownload 'http://bitbucket.org/eigen/eigen/get/3.3.3.zip'
7z x 3.3.3.zip -y > $null
$env:CMAKE_INCLUDE_PATH = "eigen-eigen-67e894c6cd8f;$env:CMAKE_INCLUDE_PATH"
build_script:
- cmake -G "%CMAKE_GENERATOR%" -A "%CMAKE_ARCH%"
-DPYBIND11_CPP_STANDARD=/std:c++%CPP%
-DPYBIND11_WERROR=ON
-DDOWNLOAD_CATCH=ON
-DCMAKE_SUPPRESS_REGENERATION=1
- set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
- cmake --build . --config %CONFIG% --target pytest -- /m /v:m /logger:%MSBuildLogger%
- cmake --build . --config %CONFIG% --target cpptest -- /m /v:m /logger:%MSBuildLogger%
- if "%CPP%"=="latest" (cmake --build . --config %CONFIG% --target test_cmake_build -- /m /v:m /logger:%MSBuildLogger%)
on_failure: if exist "tests\test_cmake_build" type tests\test_cmake_build\*.log*
CMakeCache.txt
CMakeFiles
Makefile
cmake_install.cmake
.DS_Store
*.so
*.pyd
*.dll
*.sln
*.sdf
*.opensdf
*.vcxproj
*.filters
example.dir
Win32
x64
Release
Debug
.vs
CTestTestfile.cmake
Testing
autogen
MANIFEST
/.ninja_*
/*.ninja
/docs/.build
*.py[co]
*.egg-info
*~
.*.swp
.DS_Store
/dist
/build
/cmake/
.cache/
sosize-*.txt
pybind11Config*.cmake
pybind11Targets.cmake
[submodule "tools/clang"]
path = tools/clang
url = https://github.com/wjakob/clang-cindex-python3
python:
version: 3
requirements_file: docs/requirements.txt
language: cpp
dist: trusty
sudo: false
matrix:
include:
# This config does a few things:
# - Checks C++ and Python code styles (check-style.sh and flake8).
# - Makes sure sphinx can build the docs without any errors or warnings.
# - Tests setup.py sdist and install (all header files should be present).
# - Makes sure that everything still works without optional deps (numpy/scipy/eigen) and
# also tests the automatic discovery functions in CMake (Python version, C++ standard).
- os: linux
env: STYLE DOCS PIP
cache: false
before_install:
- pyenv global $(pyenv whence 2to3) # activate all python versions
- PY_CMD=python3
- $PY_CMD -m pip install --user --upgrade pip wheel
install:
- $PY_CMD -m pip install --user --upgrade sphinx sphinx_rtd_theme breathe flake8 pep8-naming pytest
- curl -fsSL ftp://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.12.linux.bin.tar.gz | tar xz
- export PATH="$PWD/doxygen-1.8.12/bin:$PATH"
script:
- tools/check-style.sh
- flake8
- $PY_CMD -m sphinx -W -b html docs docs/.build
- |
# Make sure setup.py distributes and installs all the headers
$PY_CMD setup.py sdist
$PY_CMD -m pip install --user -U ./dist/*
installed=$($PY_CMD -c "import pybind11; print(pybind11.get_include(True) + '/pybind11')")
diff -rq $installed ./include/pybind11
- |
# Barebones build
cmake -DCMAKE_BUILD_TYPE=Debug -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON
make pytest -j 2
make cpptest -j 2
# The following are regular test configurations, including optional dependencies.
# With regard to each other they differ in Python version, C++ standard and compiler.
- os: linux
env: PYTHON=2.7 CPP=11 GCC=4.8
addons:
apt:
packages: [cmake=2.\*, cmake-data=2.\*]
- os: linux
env: PYTHON=3.6 CPP=11 GCC=4.8
addons:
apt:
sources: [deadsnakes]
packages: [python3.6-dev python3.6-venv, cmake=2.\*, cmake-data=2.\*]
- sudo: true
services: docker
env: PYTHON=2.7 CPP=14 GCC=6 CMAKE=1
- sudo: true
services: docker
env: PYTHON=3.5 CPP=14 GCC=6 DEBUG=1
- sudo: true
services: docker
env: PYTHON=3.6 CPP=17 GCC=7
- os: linux
env: PYTHON=3.6 CPP=17 CLANG=5.0
addons:
apt:
sources: [deadsnakes, llvm-toolchain-trusty-5.0, ubuntu-toolchain-r-test]
packages: [python3.6-dev python3.6-venv clang-5.0 llvm-5.0-dev, lld-5.0]
- os: osx
osx_image: xcode7.3
env: PYTHON=2.7 CPP=14 CLANG CMAKE=1
- os: osx
osx_image: xcode9
env: PYTHON=3.7 CPP=14 CLANG DEBUG=1
# Test a PyPy 2.7 build
- os: linux
env: PYPY=5.8 PYTHON=2.7 CPP=11 GCC=4.8
addons:
apt:
packages: [libblas-dev, liblapack-dev, gfortran]
# Build in 32-bit mode and tests against the CMake-installed version
- sudo: true
services: docker
env: ARCH=i386 PYTHON=3.5 CPP=14 GCC=6 INSTALL=1
script:
- |
$SCRIPT_RUN_PREFIX sh -c "set -e
cmake ${CMAKE_EXTRA_ARGS} -DPYBIND11_INSTALL=1 -DPYBIND11_TEST=0
make install
cp -a tests /pybind11-tests
mkdir /build-tests && cd /build-tests
cmake ../pybind11-tests ${CMAKE_EXTRA_ARGS} -DPYBIND11_WERROR=ON
make pytest -j 2"
cache:
directories:
- $HOME/.local/bin
- $HOME/.local/lib
- $HOME/.local/include
- $HOME/Library/Python
before_install:
- |
# Configure build variables
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
if [ -n "$CLANG" ]; then
export CXX=clang++-$CLANG CC=clang-$CLANG
EXTRA_PACKAGES+=" clang-$CLANG llvm-$CLANG-dev"
else
if [ -z "$GCC" ]; then GCC=4.8
else EXTRA_PACKAGES+=" g++-$GCC"
fi
export CXX=g++-$GCC CC=gcc-$GCC
fi
if [ "$GCC" = "6" ]; then DOCKER=${ARCH:+$ARCH/}debian:stretch
elif [ "$GCC" = "7" ]; then DOCKER=debian:buster EXTRA_PACKAGES+=" catch python3-distutils" DOWNLOAD_CATCH=OFF
fi
elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
export CXX=clang++ CC=clang;
fi
if [ -n "$CPP" ]; then CPP=-std=c++$CPP; fi
if [ "${PYTHON:0:1}" = "3" ]; then PY=3; fi
if [ -n "$DEBUG" ]; then CMAKE_EXTRA_ARGS+=" -DCMAKE_BUILD_TYPE=Debug"; fi
- |
# Initialize environment
set -e
if [ -n "$DOCKER" ]; then
docker pull $DOCKER
containerid=$(docker run --detach --tty \
--volume="$PWD":/pybind11 --workdir=/pybind11 \
--env="CC=$CC" --env="CXX=$CXX" --env="DEBIAN_FRONTEND=$DEBIAN_FRONTEND" \
--env=GCC_COLORS=\ \
$DOCKER)
SCRIPT_RUN_PREFIX="docker exec --tty $containerid"
$SCRIPT_RUN_PREFIX sh -c 'for s in 0 15; do sleep $s; apt-get update && apt-get -qy dist-upgrade && break; done'
else
if [ "$PYPY" = "5.8" ]; then
curl -fSL https://bitbucket.org/pypy/pypy/downloads/pypy2-v5.8.0-linux64.tar.bz2 | tar xj
PY_CMD=$(echo `pwd`/pypy2-v5.8.0-linux64/bin/pypy)
CMAKE_EXTRA_ARGS+=" -DPYTHON_EXECUTABLE:FILEPATH=$PY_CMD"
else
PY_CMD=python$PYTHON
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
if [ "$PY" = "3" ]; then
brew install python$PY;
else
curl -fsSL https://bootstrap.pypa.io/get-pip.py | $PY_CMD - --user
fi
fi
fi
if [ "$PY" = 3 ] || [ -n "$PYPY" ]; then
$PY_CMD -m ensurepip --user
fi
$PY_CMD -m pip install --user --upgrade pip wheel
fi
set +e
install:
- |
# Install dependencies
set -e
if [ -n "$DOCKER" ]; then
if [ -n "$DEBUG" ]; then
PY_DEBUG="python$PYTHON-dbg python$PY-scipy-dbg"
CMAKE_EXTRA_ARGS+=" -DPYTHON_EXECUTABLE=/usr/bin/python${PYTHON}dm"
fi
$SCRIPT_RUN_PREFIX sh -c "for s in 0 15; do sleep \$s; \
apt-get -qy --no-install-recommends install \
$PY_DEBUG python$PYTHON-dev python$PY-pytest python$PY-scipy \
libeigen3-dev libboost-dev cmake make ${EXTRA_PACKAGES} && break; done"
else
if [ "$CLANG" = "5.0" ]; then
if ! [ -d ~/.local/include/c++/v1 ]; then
# Neither debian nor llvm provide a libc++ 5.0 deb; luckily it's fairly quick
# to build, install (and cache), so do it ourselves:
git clone --depth=1 https://github.com/llvm-mirror/llvm.git llvm-source
git clone https://github.com/llvm-mirror/libcxx.git llvm-source/projects/libcxx -b release_50
git clone https://github.com/llvm-mirror/libcxxabi.git llvm-source/projects/libcxxabi -b release_50
mkdir llvm-build && cd llvm-build
# Building llvm requires a newer cmake than is provided by the trusty container:
CMAKE_VER=cmake-3.8.0-Linux-x86_64
curl https://cmake.org/files/v3.8/$CMAKE_VER.tar.gz | tar xz
./$CMAKE_VER/bin/cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/.local ../llvm-source
make -j2 install-cxxabi install-cxx
cp -a include/c++/v1/*cxxabi*.h ~/.local/include/c++/v1
cd ..
fi
export CXXFLAGS="-isystem $HOME/.local/include/c++/v1 -stdlib=libc++"
export LDFLAGS="-L$HOME/.local/lib -fuse-ld=lld-$CLANG"
export LD_LIBRARY_PATH="$HOME/.local/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
if [ "$CPP" = "-std=c++17" ]; then CPP="-std=c++1z"; fi
fi
export NPY_NUM_BUILD_JOBS=2
echo "Installing pytest, numpy, scipy..."
${PYPY:+travis_wait 30} $PY_CMD -m pip install --user --upgrade pytest numpy scipy \
${PYPY:+--extra-index-url https://imaginary.ca/trusty-pypi}
echo "done."
wget -q -O eigen.tar.gz https://bitbucket.org/eigen/eigen/get/3.3.3.tar.gz
tar xzf eigen.tar.gz
export CMAKE_INCLUDE_PATH="${CMAKE_INCLUDE_PATH:+$CMAKE_INCLUDE_PATH:}$PWD/eigen-eigen-67e894c6cd8f"
fi
set +e
script:
- $SCRIPT_RUN_PREFIX cmake ${CMAKE_EXTRA_ARGS}
-DPYBIND11_PYTHON_VERSION=$PYTHON
-DPYBIND11_CPP_STANDARD=$CPP
-DPYBIND11_WERROR=${WERROR:-ON}
-DDOWNLOAD_CATCH=${DOWNLOAD_CATCH:-ON}
- $SCRIPT_RUN_PREFIX make pytest -j 2
- $SCRIPT_RUN_PREFIX make cpptest -j 2
- if [ -n "$CMAKE" ]; then $SCRIPT_RUN_PREFIX make test_cmake_build; fi
after_failure: cat tests/test_cmake_build/*.log*
after_script:
- if [ -n "$DOCKER" ]; then docker stop "$containerid"; docker rm "$containerid"; fi
# CMakeLists.txt -- Build system for the pybind11 modules
#
# Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch>
#
# All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
cmake_minimum_required(VERSION 2.8.12)
if (POLICY CMP0048)
# cmake warns if loaded from a min-3.0-required parent dir, so silence the warning:
cmake_policy(SET CMP0048 NEW)
endif()
# CMake versions < 3.4.0 do not support try_compile/pthread checks without C as active language.
if(CMAKE_VERSION VERSION_LESS 3.4.0)
project(pybind11)
else()
project(pybind11 CXX)
endif()
# Check if pybind11 is being used directly or via add_subdirectory
set(PYBIND11_MASTER_PROJECT OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(PYBIND11_MASTER_PROJECT ON)
endif()
option(PYBIND11_INSTALL "Install pybind11 header files?" ${PYBIND11_MASTER_PROJECT})
option(PYBIND11_TEST "Build pybind11 test suite?" ${PYBIND11_MASTER_PROJECT})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/tools")
include(pybind11Tools)
# Cache variables so pybind11_add_module can be used in parent projects
set(PYBIND11_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}/include" CACHE INTERNAL "")
set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS} CACHE INTERNAL "")
set(PYTHON_LIBRARIES ${PYTHON_LIBRARIES} CACHE INTERNAL "")
set(PYTHON_MODULE_PREFIX ${PYTHON_MODULE_PREFIX} CACHE INTERNAL "")
set(PYTHON_MODULE_EXTENSION ${PYTHON_MODULE_EXTENSION} CACHE INTERNAL "")
set(PYTHON_VERSION_MAJOR ${PYTHON_VERSION_MAJOR} CACHE INTERNAL "")
set(PYTHON_VERSION_MINOR ${PYTHON_VERSION_MINOR} CACHE INTERNAL "")
# NB: when adding a header don't forget to also add it to setup.py
set(PYBIND11_HEADERS
include/pybind11/detail/class.h
include/pybind11/detail/common.h
include/pybind11/detail/descr.h
include/pybind11/detail/init.h
include/pybind11/detail/internals.h
include/pybind11/detail/typeid.h
include/pybind11/attr.h
include/pybind11/buffer_info.h
include/pybind11/cast.h
include/pybind11/chrono.h
include/pybind11/common.h
include/pybind11/complex.h
include/pybind11/options.h
include/pybind11/eigen.h
include/pybind11/embed.h
include/pybind11/eval.h
include/pybind11/functional.h
include/pybind11/numpy.h
include/pybind11/operators.h
include/pybind11/pybind11.h
include/pybind11/pytypes.h
include/pybind11/stl.h
include/pybind11/stl_bind.h
)
string(REPLACE "include/" "${CMAKE_CURRENT_SOURCE_DIR}/include/"
PYBIND11_HEADERS "${PYBIND11_HEADERS}")
if (PYBIND11_TEST)
add_subdirectory(tests)
endif()
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
# extract project version from source
file(STRINGS "${PYBIND11_INCLUDE_DIR}/pybind11/detail/common.h" pybind11_version_defines
REGEX "#define PYBIND11_VERSION_(MAJOR|MINOR|PATCH) ")
foreach(ver ${pybind11_version_defines})
if (ver MATCHES "#define PYBIND11_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$")
set(PYBIND11_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "")
endif()
endforeach()
set(${PROJECT_NAME}_VERSION ${PYBIND11_VERSION_MAJOR}.${PYBIND11_VERSION_MINOR}.${PYBIND11_VERSION_PATCH})
message(STATUS "pybind11 v${${PROJECT_NAME}_VERSION}")
option (USE_PYTHON_INCLUDE_DIR "Install pybind11 headers in Python include directory instead of default installation prefix" OFF)
if (USE_PYTHON_INCLUDE_DIR)
file(RELATIVE_PATH CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX} ${PYTHON_INCLUDE_DIRS})
endif()
if(NOT (CMAKE_VERSION VERSION_LESS 3.0)) # CMake >= 3.0
# Build an interface library target:
add_library(pybind11 INTERFACE)
add_library(pybind11::pybind11 ALIAS pybind11) # to match exported target
target_include_directories(pybind11 INTERFACE $<BUILD_INTERFACE:${PYBIND11_INCLUDE_DIR}>
$<BUILD_INTERFACE:${PYTHON_INCLUDE_DIRS}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_options(pybind11 INTERFACE $<BUILD_INTERFACE:${PYBIND11_CPP_STANDARD}>)
add_library(module INTERFACE)
add_library(pybind11::module ALIAS module)
if(NOT MSVC)
target_compile_options(module INTERFACE -fvisibility=hidden)
endif()
target_link_libraries(module INTERFACE pybind11::pybind11)
if(WIN32 OR CYGWIN)
target_link_libraries(module INTERFACE $<BUILD_INTERFACE:${PYTHON_LIBRARIES}>)
elseif(APPLE)
target_link_libraries(module INTERFACE "-undefined dynamic_lookup")
endif()
add_library(embed INTERFACE)
add_library(pybind11::embed ALIAS embed)
target_link_libraries(embed INTERFACE pybind11::pybind11 $<BUILD_INTERFACE:${PYTHON_LIBRARIES}>)
endif()
if (PYBIND11_INSTALL)
install(DIRECTORY ${PYBIND11_INCLUDE_DIR}/pybind11 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# GNUInstallDirs "DATADIR" wrong here; CMake search path wants "share".
set(PYBIND11_CMAKECONFIG_INSTALL_DIR "share/cmake/${PROJECT_NAME}" CACHE STRING "install path for pybind11Config.cmake")
configure_package_config_file(tools/${PROJECT_NAME}Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR})
# Remove CMAKE_SIZEOF_VOID_P from ConfigVersion.cmake since the library does
# not depend on architecture specific settings or libraries.
set(_PYBIND11_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
unset(CMAKE_SIZEOF_VOID_P)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${${PROJECT_NAME}_VERSION}
COMPATIBILITY AnyNewerVersion)
set(CMAKE_SIZEOF_VOID_P ${_PYBIND11_CMAKE_SIZEOF_VOID_P})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
tools/FindPythonLibsNew.cmake
tools/pybind11Tools.cmake
DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR})
if(NOT (CMAKE_VERSION VERSION_LESS 3.0))
if(NOT PYBIND11_EXPORT_NAME)
set(PYBIND11_EXPORT_NAME "${PROJECT_NAME}Targets")
endif()
install(TARGETS pybind11 module embed
EXPORT "${PYBIND11_EXPORT_NAME}")
if(PYBIND11_MASTER_PROJECT)
install(EXPORT "${PYBIND11_EXPORT_NAME}"
NAMESPACE "${PROJECT_NAME}::"
DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR})
endif()
endif()
endif()
Thank you for your interest in this project! Please refer to the following
sections on how to contribute code and bug reports.
### Reporting bugs
At the moment, this project is run in the spare time of a single person
([Wenzel Jakob](http://rgl.epfl.ch/people/wjakob)) with very limited resources
for issue tracker tickets. Thus, before submitting a question or bug report,
please take a moment of your time and ensure that your issue isn't already
discussed in the project documentation provided at
[http://pybind11.readthedocs.org/en/latest](http://pybind11.readthedocs.org/en/latest).
Assuming that you have identified a previously unknown problem or an important
question, it's essential that you submit a self-contained and minimal piece of
code that reproduces the problem. In other words: no external dependencies,
isolate the function(s) that cause breakage, submit matched and complete C++
and Python snippets that can be easily compiled and run on my end.
## Pull requests
Contributions are submitted, reviewed, and accepted using Github pull requests.
Please refer to [this
article](https://help.github.com/articles/using-pull-requests) for details and
adhere to the following rules to make the process as smooth as possible:
* Make a new branch for every feature you're working on.
* Make small and clean pull requests that are easy to review but make sure they
do add value by themselves.
* Add tests for any new functionality and run the test suite (``make pytest``)
to ensure that no existing features break.
* This project has a strong focus on providing general solutions using a
minimal amount of code, thus small pull requests are greatly preferred.
### Licensing of contributions
pybind11 is provided under a BSD-style license that can be found in the
``LICENSE`` file. By using, distributing, or contributing to this project, you
agree to the terms and conditions of this license.
You are under no obligation whatsoever to provide any bug fixes, patches, or
upgrades to the features, functionality or performance of the source code
("Enhancements") to anyone; however, if you choose to make your Enhancements
available either publicly, or directly to the author of this software, without
imposing a separate written license agreement for such Enhancements, then you
hereby grant the following license: a non-exclusive, royalty-free perpetual
license to install, use, modify, prepare derivative works, incorporate into
other computer software, distribute, and sublicense such enhancements or
derivative works thereof, in binary and source code form.
Make sure you've completed the following steps before submitting your issue -- thank you!
1. Check if your question has already been answered in the [FAQ](http://pybind11.readthedocs.io/en/latest/faq.html) section.
2. Make sure you've read the [documentation](http://pybind11.readthedocs.io/en/latest/). Your issue may be addressed there.
3. If those resources didn't help and you only have a short question (not a bug report), consider asking in the [Gitter chat room](https://gitter.im/pybind/Lobby).
4. If you have a genuine bug report or a more complex question which is not answered in the previous items (or not suitable for chat), please fill in the details below.
5. Include a self-contained and minimal piece of code that reproduces the problem. If that's not possible, try to make the description as clear as possible.
*After reading, remove this checklist and the template text in parentheses below.*
## Issue description
(Provide a short description, state the expected behavior and what actually happens.)
## Reproducible example code
(The code should be minimal, have no external dependencies, isolate the function(s) that cause breakage. Submit matched and complete C++ and Python snippets that can be easily compiled and run to diagnose the issue.)
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>, All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Please also refer to the file CONTRIBUTING.md, which clarifies licensing of
external contributions to this project including patches, pull requests, etc.
recursive-include include/pybind11 *.h
include LICENSE README.md CONTRIBUTING.md
![pybind11 logo](https://github.com/pybind/pybind11/raw/master/docs/pybind11-logo.png)
# pybind11 — Seamless operability between C++11 and Python
[![Documentation Status](https://readthedocs.org/projects/pybind11/badge/?version=master)](http://pybind11.readthedocs.org/en/master/?badge=master)
[![Documentation Status](https://readthedocs.org/projects/pybind11/badge/?version=stable)](http://pybind11.readthedocs.org/en/stable/?badge=stable)
[![Gitter chat](https://img.shields.io/gitter/room/gitterHQ/gitter.svg)](https://gitter.im/pybind/Lobby)
[![Build Status](https://travis-ci.org/pybind/pybind11.svg?branch=master)](https://travis-ci.org/pybind/pybind11)
[![Build status](https://ci.appveyor.com/api/projects/status/riaj54pn4h08xy40?svg=true)](https://ci.appveyor.com/project/wjakob/pybind11)
**pybind11** is a lightweight header-only library that exposes C++ types in Python
and vice versa, mainly to create Python bindings of existing C++ code. Its
goals and syntax are similar to the excellent
[Boost.Python](http://www.boost.org/doc/libs/1_58_0/libs/python/doc/) library
by David Abrahams: to minimize boilerplate code in traditional extension
modules by inferring type information using compile-time introspection.
The main issue with Boost.Python—and the reason for creating such a similar
project—is Boost. Boost is an enormously large and complex suite of utility
libraries that works with almost every C++ compiler in existence. This
compatibility has its cost: arcane template tricks and workarounds are
necessary to support the oldest and buggiest of compiler specimens. Now that
C++11-compatible compilers are widely available, this heavy machinery has
become an excessively large and unnecessary dependency.
Think of this library as a tiny self-contained version of Boost.Python with
everything stripped away that isn't relevant for binding generation. Without
comments, the core header files only require ~4K lines of code and depend on
Python (2.7 or 3.x, or PyPy2.7 >= 5.7) and the C++ standard library. This