2020-09-17 19:40:09 +00:00
|
|
|
|
.. figure:: https://github.com/pybind/pybind11/raw/master/docs/pybind11-logo.png
|
|
|
|
|
:alt: pybind11 logo
|
|
|
|
|
|
2022-05-12 21:45:55 +00:00
|
|
|
|
**pybind11 — Seamless operability between C++ and Python**
|
2020-09-17 19:40:09 +00:00
|
|
|
|
|
2021-07-29 23:10:18 +00:00
|
|
|
|
|Latest Documentation Status| |Stable Documentation Status| |Gitter chat| |GitHub Discussions| |CI| |Build status|
|
2020-09-17 19:40:09 +00:00
|
|
|
|
|
2020-11-15 17:23:33 +00:00
|
|
|
|
|Repology| |PyPI package| |Conda-forge| |Python Versions|
|
|
|
|
|
|
|
|
|
|
`Setuptools example <https://github.com/pybind/python_example>`_
|
|
|
|
|
• `Scikit-build example <https://github.com/pybind/scikit_build_example>`_
|
|
|
|
|
• `CMake example <https://github.com/pybind/cmake_example>`_
|
|
|
|
|
|
2020-12-22 13:50:45 +00:00
|
|
|
|
.. start
|
|
|
|
|
|
|
|
|
|
|
2020-09-17 19:40:09 +00:00
|
|
|
|
**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
|
2022-02-12 00:06:16 +00:00
|
|
|
|
with everything stripped away that isn't relevant for binding
|
2020-09-17 19:40:09 +00:00
|
|
|
|
generation. Without comments, the core header files only require ~4K
|
2022-02-12 00:06:16 +00:00
|
|
|
|
lines of code and depend on Python (3.6+, or PyPy) and the C++
|
2020-09-17 19:40:09 +00:00
|
|
|
|
standard library. This compact implementation was possible thanks to
|
|
|
|
|
some of the new C++11 language features (specifically: tuples, lambda
|
|
|
|
|
functions and variadic templates). Since its creation, this library has
|
|
|
|
|
grown beyond Boost.Python in many ways, leading to dramatically simpler
|
|
|
|
|
binding code in many common situations.
|
|
|
|
|
|
|
|
|
|
Tutorial and reference documentation is provided at
|
2020-10-12 20:31:44 +00:00
|
|
|
|
`pybind11.readthedocs.io <https://pybind11.readthedocs.io/en/latest>`_.
|
2020-09-17 19:40:09 +00:00
|
|
|
|
A PDF version of the manual is available
|
2020-10-18 10:51:36 +00:00
|
|
|
|
`here <https://pybind11.readthedocs.io/_/downloads/en/latest/pdf/>`_.
|
2020-09-17 19:40:09 +00:00
|
|
|
|
And the source code is always available at
|
|
|
|
|
`github.com/pybind/pybind11 <https://github.com/pybind/pybind11>`_.
|
|
|
|
|
|
2020-10-18 18:31:28 +00:00
|
|
|
|
|
2020-09-17 19:40:09 +00:00
|
|
|
|
Core features
|
|
|
|
|
-------------
|
|
|
|
|
|
2020-10-18 18:31:28 +00:00
|
|
|
|
|
2020-09-17 19:40:09 +00:00
|
|
|
|
pybind11 can map the following core C++ features to Python:
|
|
|
|
|
|
2020-10-18 18:31:28 +00:00
|
|
|
|
- Functions accepting and returning custom data structures per value,
|
|
|
|
|
reference, or pointer
|
|
|
|
|
- Instance methods and static methods
|
|
|
|
|
- Overloaded functions
|
|
|
|
|
- Instance attributes and static attributes
|
|
|
|
|
- Arbitrary exception types
|
|
|
|
|
- Enumerations
|
|
|
|
|
- Callbacks
|
|
|
|
|
- Iterators and ranges
|
|
|
|
|
- Custom operators
|
|
|
|
|
- Single and multiple inheritance
|
|
|
|
|
- STL data structures
|
|
|
|
|
- Smart pointers with reference counting like ``std::shared_ptr``
|
|
|
|
|
- Internal references with correct reference counting
|
|
|
|
|
- C++ classes with virtual (and pure virtual) methods can be extended
|
|
|
|
|
in Python
|
2020-09-17 19:40:09 +00:00
|
|
|
|
|
|
|
|
|
Goodies
|
|
|
|
|
-------
|
|
|
|
|
|
|
|
|
|
In addition to the core functionality, pybind11 provides some extra
|
|
|
|
|
goodies:
|
|
|
|
|
|
2022-02-12 00:06:16 +00:00
|
|
|
|
- Python 3.6+, and PyPy3 7.3 are supported with an implementation-agnostic
|
|
|
|
|
interface (pybind11 2.9 was the last version to support Python 2 and 3.5).
|
2020-09-17 19:40:09 +00:00
|
|
|
|
|
2020-10-18 18:31:28 +00:00
|
|
|
|
- It is possible to bind C++11 lambda functions with captured
|
|
|
|
|
variables. The lambda capture data is stored inside the resulting
|
|
|
|
|
Python function object.
|
2020-09-17 19:40:09 +00:00
|
|
|
|
|
2020-10-18 18:31:28 +00:00
|
|
|
|
- pybind11 uses C++11 move constructors and move assignment operators
|
|
|
|
|
whenever possible to efficiently transfer custom data types.
|
2020-09-17 19:40:09 +00:00
|
|
|
|
|
2022-02-12 00:06:16 +00:00
|
|
|
|
- It's easy to expose the internal storage of custom data types through
|
|
|
|
|
Pythons' buffer protocols. This is handy e.g. for fast conversion
|
2020-10-18 18:31:28 +00:00
|
|
|
|
between C++ matrix classes like Eigen and NumPy without expensive
|
|
|
|
|
copy operations.
|
2020-09-17 19:40:09 +00:00
|
|
|
|
|
2020-10-18 18:31:28 +00:00
|
|
|
|
- pybind11 can automatically vectorize functions so that they are
|
|
|
|
|
transparently applied to all entries of one or more NumPy array
|
|
|
|
|
arguments.
|
2020-09-17 19:40:09 +00:00
|
|
|
|
|
2021-07-15 19:01:13 +00:00
|
|
|
|
- Python's slice-based access and assignment operations can be
|
2020-10-18 18:31:28 +00:00
|
|
|
|
supported with just a few lines of code.
|
2020-09-17 19:40:09 +00:00
|
|
|
|
|
2020-10-18 18:31:28 +00:00
|
|
|
|
- Everything is contained in just a few header files; there is no need
|
|
|
|
|
to link against any additional libraries.
|
2020-09-17 19:40:09 +00:00
|
|
|
|
|
2020-10-18 18:31:28 +00:00
|
|
|
|
- Binaries are generally smaller by a factor of at least 2 compared to
|
|
|
|
|
equivalent bindings generated by Boost.Python. A recent pybind11
|
|
|
|
|
conversion of PyRosetta, an enormous Boost.Python binding project,
|
2021-11-18 13:42:08 +00:00
|
|
|
|
`reported <https://graylab.jhu.edu/Sergey/2016.RosettaCon/PyRosetta-4.pdf>`_
|
2020-10-18 18:31:28 +00:00
|
|
|
|
a binary size reduction of **5.4x** and compile time reduction by
|
|
|
|
|
**5.8x**.
|
2020-09-17 19:40:09 +00:00
|
|
|
|
|
2020-10-18 18:31:28 +00:00
|
|
|
|
- Function signatures are precomputed at compile time (using
|
|
|
|
|
``constexpr``), leading to smaller binaries.
|
2020-09-17 19:40:09 +00:00
|
|
|
|
|
2020-10-18 18:31:28 +00:00
|
|
|
|
- With little extra effort, C++ types can be pickled and unpickled
|
|
|
|
|
similar to regular Python objects.
|
2020-09-17 19:40:09 +00:00
|
|
|
|
|
|
|
|
|
Supported compilers
|
|
|
|
|
-------------------
|
|
|
|
|
|
2022-02-12 00:06:16 +00:00
|
|
|
|
1. Clang/LLVM 3.3 or newer (for Apple Xcode's clang, this is 5.0.0 or
|
2020-09-17 19:40:09 +00:00
|
|
|
|
newer)
|
|
|
|
|
2. GCC 4.8 or newer
|
Dropping MSVC 2015 (#3722)
* Changing `_MSC_VER` guard to `< 1910` (dropping MSVC 2015).
* Removing MSVC 2015 from ci.yml, and .appveyor.yml entirely.
* Bringing back .appveyor.yml from master.
* appveyor Visual Studio 2017
* 1st manual pass, builds & tests with unix_clang, before pre-commit.
* After clang-format (via pre-commit).
* Manual pass looking for "2015", builds & tests with unix_clang, before pre-commit.
* Backtracking for include/pybind11 changes in previous commit.
git checkout d07865846c7d31dd61111e6df801864327b65070 include/pybind11/attr.h include/pybind11/detail/common.h include/pybind11/functional.h
--------------------
CI #4160 errors observed:
https://github.com/pybind/pybind11/pull/3722/commits/2a26873727214c5f1e159cba98f5c625b908381a
https://github.com/pybind/pybind11/runs/5168332130?check_suite_focus=true
$ grep ' error C' *.txt | sed 's/2022-02-12[^ ]*//' | sed 's/^[0-9][0-9]*//' | sed 's/^.*\.txt: //' | sort | uniqD:\a\pybind11\pybind11\include\pybind11\cast.h(1364,1): error C2752: 'pybind11::detail::type_caster<Eigen::Ref<Eigen::Vector3f,0,pybind11::EigenDStride>,void>': more than one partial specialization matches the template argument list [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]
d:\a\pybind11\pybind11\include\pybind11\detail/common.h(1023): error C2737: 'pybind11::overload_cast': 'constexpr' object must be initialized [D:\a\pybind11\pybind11\build\tests\cross_module_gil_utils.vcxproj]
d:\a\pybind11\pybind11\include\pybind11\detail/common.h(1023): error C2737: 'pybind11::overload_cast': 'constexpr' object must be initialized [D:\a\pybind11\pybind11\build\tests\pybind11_cross_module_tests.vcxproj]
d:\a\pybind11\pybind11\include\pybind11\detail/common.h(1023): error C2737: 'pybind11::overload_cast': 'constexpr' object must be initialized [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]
d:\a\pybind11\pybind11\include\pybind11\detail/common.h(1023): error C2737: 'pybind11::overload_cast': 'constexpr' object must be initialized [D:\a\pybind11\pybind11\build\tests\test_embed\external_module.vcxproj]
D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]
D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
$ grep ': error C2737' *.txt | sed 's/^.*MSVC//' | sed 's/___.*//' | sort | uniq
_2017
$ grep ': error C2752' *.txt
3______3.8_____MSVC_2019_____x86_-DCMAKE_CXX_STANDARD=17.txt:2022-02-12T16:12:45.9921122Z D:\a\pybind11\pybind11\include\pybind11\cast.h(1364,1): error C2752: 'pybind11::detail::type_caster<Eigen::Ref<Eigen::Vector3f,0,pybind11::EigenDStride>,void>': more than one partial specialization matches the template argument list [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]
$ grep ': fatal error C1001:' *.txt
10______pypy-3.8-v7.3.7_____windows-2022_____x64.txt:2022-02-12T16:12:56.3163683Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
1______3.6_____MSVC_2019_____x86.txt:2022-02-12T16:12:47.6774625Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]
16______3.6_____windows-latest_____x64_-DPYBIND11_FINDPYTHON=ON.txt:2022-02-12T16:12:27.0556151Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
17______3.9_____windows-2019_____x64.txt:2022-02-12T16:12:30.3822566Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
2______3.7_____MSVC_2019_____x86.txt:2022-02-12T16:12:38.7018911Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\build\tests\pybind11_tests.vcxproj]
6______3.6_____windows-2022_____x64.txt:2022-02-12T16:12:00.4513642Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
7______3.9_____windows-2022_____x64.txt:2022-02-12T16:11:43.6306160Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
8______3.10_____windows-2022_____x64.txt:2022-02-12T16:11:49.9589644Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
9______pypy-3.7-v7.3.7_____windows-2022_____x64.txt:2022-02-12T16:11:53.7912112Z D:\a\pybind11\pybind11\include\pybind11\detail/common.h(624): fatal error C1001: Internal compiler error. [D:\a\pybind11\pybind11\tests\pybind11_tests.vcxproj]
* common.h: is_template_base_of
* Re-applying 4 changes from 2a26873727214c5f1e159cba98f5c625b908381a that work universally.
* `overload_cast = {};` only for MSVC 2017 and Clang 5
* Refining condition for using is_template_base_of workaround.
* Undoing MSVC 2015 workaround in test_constants_and_functions.cpp
* CentOS7: silence_unused_warnings
* Tweaks in response to reviews.
* Adding windows-2022 C++20
* Trying another way of adding windows-2022 C++20
2022-02-14 19:36:22 +00:00
|
|
|
|
3. Microsoft Visual Studio 2017 or newer
|
fix: Intel ICC C++17 compatibility (#2729)
* CI: Intel icc/icpc via oneAPI
Add testing for Intel icc/icpc via the oneAPI images.
Intel oneAPI is in a late beta stage, currently shipping
oneAPI beta09 with ICC 20.2.
CI: Skip Interpreter Tests for Intel
Cannot find how to add this, neiter the package `libc6-dev` nor
`intel-oneapi-mkl-devel` help when installed to solve this:
```
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - not found
CMake Error at /__t/cmake/3.18.4/x64/cmake-3.18.4-Linux-x86_64/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
/__t/cmake/3.18.4/x64/cmake-3.18.4-Linux-x86_64/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
/__t/cmake/3.18.4/x64/cmake-3.18.4-Linux-x86_64/share/cmake-3.18/Modules/FindThreads.cmake:234 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
tests/test_embed/CMakeLists.txt:17 (find_package)
```
CI: libc6-dev from GCC for ICC
CI: Run bare metal for oneAPI
CI: Ubuntu 18.04 for oneAPI
CI: Intel +Catch -Eigen
CI: CMake from Apt (ICC tests)
CI: Replace Intel Py with GCC Py
CI: Intel w/o GCC's Eigen
CI: ICC with verbose make
[Debug] Find core dump
tests: use arg{} instead of arg() for Intel
tests: adding a few more missing {}
fix: sync with @tobiasleibner's branch
fix: try ubuntu 20-04
fix: drop exit 1
docs: Apply suggestions from code review
Co-authored-by: Tobias Leibner <tobias.leibner@googlemail.com>
Workaround for ICC enable_if issues
Another workaround for ICC's enable_if issues
fix error in previous commit
Disable one test for the Intel compiler in C++17 mode
Add back one instance of py::arg().noconvert()
Add NOLINT to fix clang-tidy check
Work around for ICC internal error in PYBIND11_EXPAND_SIDE_EFFECTS in C++17 mode
CI: Intel ICC with C++17
docs: pybind11/numpy.h does not require numpy at build time. (#2720)
This is nice enough to be mentioned explicitly in the docs.
docs: Update warning about Python 3.9.0 UB, now that 3.9.1 has been released (#2719)
Adjusting `type_caster<std::reference_wrapper<T>>` to support const/non-const propagation in `cast_op`. (#2705)
* Allow type_caster of std::reference_wrapper<T> to be the same as a native reference.
Before, both std::reference_wrapper<T> and std::reference_wrapper<const T> would
invoke cast_op<type>. This doesn't allow the type_caster<> specialization for T
to distinguish reference_wrapper types from value types.
After, the type_caster<> specialization invokes cast_op<type&>, which allows
reference_wrapper to behave in the same way as a native reference type.
* Add tests/examples for std::reference_wrapper<const T>
* Add tests which use mutable/immutable variants
This test is a chimera; it blends the pybind11 casters with a custom
pytype implementation that supports immutable and mutable calls.
In order to detect the immutable/mutable state, the cast_op needs
to propagate it, even through e.g. std::reference<const T>
Note: This is still a work in progress; some things are crashing,
which likely means that I have a refcounting bug or something else
missing.
* Add/finish tests that distinguish const& from &
Fixes the bugs in my custom python type implementation,
demonstrate test that requires const& and reference_wrapper<const T>
being treated differently from Non-const.
* Add passing a const to non-const method.
* Demonstrate non-const conversion of reference_wrapper in tests.
Apply formatting presubmit check.
* Fix build errors from presubmit checks.
* Try and fix a few more CI errors
* More CI fixes.
* More CI fixups.
* Try and get PyPy to work.
* Additional minor fixups. Getting close to CI green.
* More ci fixes?
* fix clang-tidy warnings from presubmit
* fix more clang-tidy warnings
* minor comment and consistency cleanups
* PyDECREF -> Py_DECREF
* copy/move constructors
* Resolve codereview comments
* more review comment fixes
* review comments: remove spurious &
* Make the test fail even when the static_assert is commented out.
This expands the test_freezable_type_caster a bit by:
1/ adding accessors .is_immutable and .addr to compare identity
from python.
2/ Changing the default cast_op of the type_caster<> specialization
to return a non-const value. In normal codepaths this is a reasonable
default.
3/ adding roundtrip variants to exercise the by reference, by pointer
and by reference_wrapper in all call paths. In conjunction with 2/, this
demonstrates the failure case of the existing std::reference_wrpper conversion,
which now loses const in a similar way that happens when using the default cast_op_type<>.
* apply presubmit formatting
* Revert inclusion of test_freezable_type_caster
There's some concern that this test is a bit unwieldly because of the use
of the raw <Python.h> functions. Removing for now.
* Add a test that validates const references propagation.
This test verifies that cast_op may be used to correctly detect
const reference types when used with std::reference_wrapper.
* mend
* Review comments based changes.
1. std::add_lvalue_reference<type> -> type&
2. Simplify the test a little more; we're never returning the ConstRefCaster
type so the class_ definition can be removed.
* formatted files again.
* Move const_ref_caster test to builtin_casters
* Review comments: use cast_op and adjust some comments.
* Simplify ConstRefCasted test
I like this version better as it moves the assertion that matters
back into python.
ci: drop pypy2 linux, PGI 20.7, add Python 10 dev (#2724)
* ci: drop pypy2 linux, add Python 10 dev
* ci: fix mistake
* ci: commented-out PGI 20.11, drop 20.7
fix: regression with installed pybind11 overriding local one (#2716)
* fix: regression with installed pybind11 overriding discovered one
Closes #2709
* docs: wording incorrect
style: remove redundant instance->owned = true (#2723)
which was just before set to True in instance->allocate_layout()
fix: also throw in the move-constructor added by the PYBIND11_OBJECT macro, after the argument has been moved-out (if necessary) (#2701)
Make args_are_all_* ICC workarounds unconditional
Disable test_aligned on Intel ICC
Fix test_aligned on Intel ICC
Skip test_python_alreadyset_in_destructor on Intel ICC
Fix test_aligned again
ICC CI: Downgrade pytest
pytest 6 does not capture the `discard_as_unraisable` stderr and
just writes a warning with its content instead.
* refactor: simpler Intel workaround, suggested by @laramiel
* fix: try version with impl to see if it is easier to compile
* docs: update README for ICC
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
2021-01-18 00:53:07 +00:00
|
|
|
|
4. Intel classic C++ compiler 18 or newer (ICC 20.2 tested in CI)
|
2020-12-16 02:07:41 +00:00
|
|
|
|
5. Cygwin/GCC (previously tested on 2.5.1)
|
fix: Intel ICC C++17 compatibility (#2729)
* CI: Intel icc/icpc via oneAPI
Add testing for Intel icc/icpc via the oneAPI images.
Intel oneAPI is in a late beta stage, currently shipping
oneAPI beta09 with ICC 20.2.
CI: Skip Interpreter Tests for Intel
Cannot find how to add this, neiter the package `libc6-dev` nor
`intel-oneapi-mkl-devel` help when installed to solve this:
```
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - not found
CMake Error at /__t/cmake/3.18.4/x64/cmake-3.18.4-Linux-x86_64/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
/__t/cmake/3.18.4/x64/cmake-3.18.4-Linux-x86_64/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
/__t/cmake/3.18.4/x64/cmake-3.18.4-Linux-x86_64/share/cmake-3.18/Modules/FindThreads.cmake:234 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
tests/test_embed/CMakeLists.txt:17 (find_package)
```
CI: libc6-dev from GCC for ICC
CI: Run bare metal for oneAPI
CI: Ubuntu 18.04 for oneAPI
CI: Intel +Catch -Eigen
CI: CMake from Apt (ICC tests)
CI: Replace Intel Py with GCC Py
CI: Intel w/o GCC's Eigen
CI: ICC with verbose make
[Debug] Find core dump
tests: use arg{} instead of arg() for Intel
tests: adding a few more missing {}
fix: sync with @tobiasleibner's branch
fix: try ubuntu 20-04
fix: drop exit 1
docs: Apply suggestions from code review
Co-authored-by: Tobias Leibner <tobias.leibner@googlemail.com>
Workaround for ICC enable_if issues
Another workaround for ICC's enable_if issues
fix error in previous commit
Disable one test for the Intel compiler in C++17 mode
Add back one instance of py::arg().noconvert()
Add NOLINT to fix clang-tidy check
Work around for ICC internal error in PYBIND11_EXPAND_SIDE_EFFECTS in C++17 mode
CI: Intel ICC with C++17
docs: pybind11/numpy.h does not require numpy at build time. (#2720)
This is nice enough to be mentioned explicitly in the docs.
docs: Update warning about Python 3.9.0 UB, now that 3.9.1 has been released (#2719)
Adjusting `type_caster<std::reference_wrapper<T>>` to support const/non-const propagation in `cast_op`. (#2705)
* Allow type_caster of std::reference_wrapper<T> to be the same as a native reference.
Before, both std::reference_wrapper<T> and std::reference_wrapper<const T> would
invoke cast_op<type>. This doesn't allow the type_caster<> specialization for T
to distinguish reference_wrapper types from value types.
After, the type_caster<> specialization invokes cast_op<type&>, which allows
reference_wrapper to behave in the same way as a native reference type.
* Add tests/examples for std::reference_wrapper<const T>
* Add tests which use mutable/immutable variants
This test is a chimera; it blends the pybind11 casters with a custom
pytype implementation that supports immutable and mutable calls.
In order to detect the immutable/mutable state, the cast_op needs
to propagate it, even through e.g. std::reference<const T>
Note: This is still a work in progress; some things are crashing,
which likely means that I have a refcounting bug or something else
missing.
* Add/finish tests that distinguish const& from &
Fixes the bugs in my custom python type implementation,
demonstrate test that requires const& and reference_wrapper<const T>
being treated differently from Non-const.
* Add passing a const to non-const method.
* Demonstrate non-const conversion of reference_wrapper in tests.
Apply formatting presubmit check.
* Fix build errors from presubmit checks.
* Try and fix a few more CI errors
* More CI fixes.
* More CI fixups.
* Try and get PyPy to work.
* Additional minor fixups. Getting close to CI green.
* More ci fixes?
* fix clang-tidy warnings from presubmit
* fix more clang-tidy warnings
* minor comment and consistency cleanups
* PyDECREF -> Py_DECREF
* copy/move constructors
* Resolve codereview comments
* more review comment fixes
* review comments: remove spurious &
* Make the test fail even when the static_assert is commented out.
This expands the test_freezable_type_caster a bit by:
1/ adding accessors .is_immutable and .addr to compare identity
from python.
2/ Changing the default cast_op of the type_caster<> specialization
to return a non-const value. In normal codepaths this is a reasonable
default.
3/ adding roundtrip variants to exercise the by reference, by pointer
and by reference_wrapper in all call paths. In conjunction with 2/, this
demonstrates the failure case of the existing std::reference_wrpper conversion,
which now loses const in a similar way that happens when using the default cast_op_type<>.
* apply presubmit formatting
* Revert inclusion of test_freezable_type_caster
There's some concern that this test is a bit unwieldly because of the use
of the raw <Python.h> functions. Removing for now.
* Add a test that validates const references propagation.
This test verifies that cast_op may be used to correctly detect
const reference types when used with std::reference_wrapper.
* mend
* Review comments based changes.
1. std::add_lvalue_reference<type> -> type&
2. Simplify the test a little more; we're never returning the ConstRefCaster
type so the class_ definition can be removed.
* formatted files again.
* Move const_ref_caster test to builtin_casters
* Review comments: use cast_op and adjust some comments.
* Simplify ConstRefCasted test
I like this version better as it moves the assertion that matters
back into python.
ci: drop pypy2 linux, PGI 20.7, add Python 10 dev (#2724)
* ci: drop pypy2 linux, add Python 10 dev
* ci: fix mistake
* ci: commented-out PGI 20.11, drop 20.7
fix: regression with installed pybind11 overriding local one (#2716)
* fix: regression with installed pybind11 overriding discovered one
Closes #2709
* docs: wording incorrect
style: remove redundant instance->owned = true (#2723)
which was just before set to True in instance->allocate_layout()
fix: also throw in the move-constructor added by the PYBIND11_OBJECT macro, after the argument has been moved-out (if necessary) (#2701)
Make args_are_all_* ICC workarounds unconditional
Disable test_aligned on Intel ICC
Fix test_aligned on Intel ICC
Skip test_python_alreadyset_in_destructor on Intel ICC
Fix test_aligned again
ICC CI: Downgrade pytest
pytest 6 does not capture the `discard_as_unraisable` stderr and
just writes a warning with its content instead.
* refactor: simpler Intel workaround, suggested by @laramiel
* fix: try version with impl to see if it is easier to compile
* docs: update README for ICC
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com>
2021-01-18 00:53:07 +00:00
|
|
|
|
6. NVCC (CUDA 11.0 tested in CI)
|
|
|
|
|
7. NVIDIA PGI (20.9 tested in CI)
|
2020-09-17 19:40:09 +00:00
|
|
|
|
|
|
|
|
|
About
|
|
|
|
|
-----
|
|
|
|
|
|
|
|
|
|
This project was created by `Wenzel
|
|
|
|
|
Jakob <http://rgl.epfl.ch/people/wjakob>`_. Significant features and/or
|
|
|
|
|
improvements to the code were contributed by Jonas Adler, Lori A. Burns,
|
2021-08-23 22:42:19 +00:00
|
|
|
|
Sylvain Corlay, Eric Cousineau, Aaron Gokaslan, Ralf Grosse-Kunstleve, Trent Houliston, Axel
|
2023-07-15 16:58:54 +00:00
|
|
|
|
Huebl, @hulucc, Yannick Jadoul, Sergey Lyskov, Johan Mabille, Tomasz Miąsko,
|
2021-08-23 22:42:19 +00:00
|
|
|
|
Dean Moldovan, Ben Pritchard, Jason Rhinelander, Boris Schäling, Pim
|
2020-10-20 14:56:02 +00:00
|
|
|
|
Schellart, Henry Schreiner, Ivan Smirnov, Boris Staletic, and Patrick Stewart.
|
2020-09-17 19:40:09 +00:00
|
|
|
|
|
2020-10-20 19:14:40 +00:00
|
|
|
|
We thank Google for a generous financial contribution to the continuous
|
|
|
|
|
integration infrastructure used by this project.
|
|
|
|
|
|
|
|
|
|
|
2020-09-17 19:40:09 +00:00
|
|
|
|
Contributing
|
|
|
|
|
~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
See the `contributing
|
|
|
|
|
guide <https://github.com/pybind/pybind11/blob/master/.github/CONTRIBUTING.md>`_
|
|
|
|
|
for information on building and contributing to pybind11.
|
|
|
|
|
|
|
|
|
|
License
|
|
|
|
|
~~~~~~~
|
|
|
|
|
|
|
|
|
|
pybind11 is provided under a BSD-style license that can be found in the
|
|
|
|
|
`LICENSE <https://github.com/pybind/pybind11/blob/master/LICENSE>`_
|
|
|
|
|
file. By using, distributing, or contributing to this project, you agree
|
|
|
|
|
to the terms and conditions of this license.
|
|
|
|
|
|
2020-09-17 21:53:35 +00:00
|
|
|
|
.. |Latest Documentation Status| image:: https://readthedocs.org/projects/pybind11/badge?version=latest
|
2020-09-18 01:18:15 +00:00
|
|
|
|
:target: http://pybind11.readthedocs.org/en/latest
|
2020-12-22 13:50:45 +00:00
|
|
|
|
.. |Stable Documentation Status| image:: https://img.shields.io/badge/docs-stable-blue.svg
|
2020-09-18 01:18:15 +00:00
|
|
|
|
:target: http://pybind11.readthedocs.org/en/stable
|
2020-09-17 19:40:09 +00:00
|
|
|
|
.. |Gitter chat| image:: https://img.shields.io/gitter/room/gitterHQ/gitter.svg
|
|
|
|
|
:target: https://gitter.im/pybind/Lobby
|
|
|
|
|
.. |CI| image:: https://github.com/pybind/pybind11/workflows/CI/badge.svg
|
|
|
|
|
:target: https://github.com/pybind/pybind11/actions
|
|
|
|
|
.. |Build status| image:: https://ci.appveyor.com/api/projects/status/riaj54pn4h08xy40?svg=true
|
|
|
|
|
:target: https://ci.appveyor.com/project/wjakob/pybind11
|
2020-12-22 13:50:45 +00:00
|
|
|
|
.. |PyPI package| image:: https://img.shields.io/pypi/v/pybind11.svg
|
2020-11-15 17:23:33 +00:00
|
|
|
|
:target: https://pypi.org/project/pybind11/
|
2020-12-22 13:50:45 +00:00
|
|
|
|
.. |Conda-forge| image:: https://img.shields.io/conda/vn/conda-forge/pybind11.svg
|
2020-11-15 17:23:33 +00:00
|
|
|
|
:target: https://github.com/conda-forge/pybind11-feedstock
|
|
|
|
|
.. |Repology| image:: https://repology.org/badge/latest-versions/python:pybind11.svg
|
|
|
|
|
:target: https://repology.org/project/python:pybind11/versions
|
2020-12-22 13:50:45 +00:00
|
|
|
|
.. |Python Versions| image:: https://img.shields.io/pypi/pyversions/pybind11.svg
|
2020-11-15 17:23:33 +00:00
|
|
|
|
:target: https://pypi.org/project/pybind11/
|
2021-07-29 23:10:18 +00:00
|
|
|
|
.. |GitHub Discussions| image:: https://img.shields.io/static/v1?label=Discussions&message=Ask&color=blue&logo=github
|
|
|
|
|
:target: https://github.com/pybind/pybind11/discussions
|