aboutsummaryrefslogtreecommitdiffstats
path: root/3rdparty/pybind11/docs
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/pybind11/docs')
-rw-r--r--3rdparty/pybind11/docs/Doxyfile4
-rw-r--r--3rdparty/pybind11/docs/_static/css/custom.css3
-rw-r--r--3rdparty/pybind11/docs/advanced/cast/custom.rst8
-rw-r--r--3rdparty/pybind11/docs/advanced/cast/eigen.rst6
-rw-r--r--3rdparty/pybind11/docs/advanced/cast/overview.rst181
-rw-r--r--3rdparty/pybind11/docs/advanced/cast/stl.rst19
-rw-r--r--3rdparty/pybind11/docs/advanced/cast/strings.rst51
-rw-r--r--3rdparty/pybind11/docs/advanced/classes.rst144
-rw-r--r--3rdparty/pybind11/docs/advanced/embedding.rst27
-rw-r--r--3rdparty/pybind11/docs/advanced/exceptions.rst132
-rw-r--r--3rdparty/pybind11/docs/advanced/functions.rst87
-rw-r--r--3rdparty/pybind11/docs/advanced/misc.rst2
-rw-r--r--3rdparty/pybind11/docs/advanced/pycpp/numpy.rst67
-rw-r--r--3rdparty/pybind11/docs/advanced/pycpp/object.rst37
-rw-r--r--3rdparty/pybind11/docs/advanced/pycpp/utilities.rst23
-rw-r--r--3rdparty/pybind11/docs/advanced/smart_ptrs.rst3
-rw-r--r--3rdparty/pybind11/docs/basics.rst20
-rw-r--r--3rdparty/pybind11/docs/benchmark.py33
-rw-r--r--3rdparty/pybind11/docs/changelog.rst934
-rw-r--r--3rdparty/pybind11/docs/classes.rst59
-rw-r--r--3rdparty/pybind11/docs/compiling.rst96
-rw-r--r--3rdparty/pybind11/docs/conf.py40
-rw-r--r--3rdparty/pybind11/docs/faq.rst52
-rw-r--r--3rdparty/pybind11/docs/installing.rst4
-rw-r--r--3rdparty/pybind11/docs/limitations.rst20
-rw-r--r--3rdparty/pybind11/docs/pybind11-logo.pngbin58510 -> 61034 bytes
-rw-r--r--3rdparty/pybind11/docs/reference.rst15
-rw-r--r--3rdparty/pybind11/docs/release.rst80
-rw-r--r--3rdparty/pybind11/docs/requirements.txt13
-rw-r--r--3rdparty/pybind11/docs/upgrade.rst46
30 files changed, 1739 insertions, 467 deletions
diff --git a/3rdparty/pybind11/docs/Doxyfile b/3rdparty/pybind11/docs/Doxyfile
index c8562952..09138db3 100644
--- a/3rdparty/pybind11/docs/Doxyfile
+++ b/3rdparty/pybind11/docs/Doxyfile
@@ -18,6 +18,4 @@ ALIASES += "endrst=\endverbatim"
QUIET = YES
WARNINGS = YES
WARN_IF_UNDOCUMENTED = NO
-PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS \
- PY_MAJOR_VERSION=3 \
- PYBIND11_NOINLINE
+PREDEFINED = PYBIND11_NOINLINE
diff --git a/3rdparty/pybind11/docs/_static/css/custom.css b/3rdparty/pybind11/docs/_static/css/custom.css
new file mode 100644
index 00000000..7a49a6ac
--- /dev/null
+++ b/3rdparty/pybind11/docs/_static/css/custom.css
@@ -0,0 +1,3 @@
+.highlight .go {
+ color: #707070;
+}
diff --git a/3rdparty/pybind11/docs/advanced/cast/custom.rst b/3rdparty/pybind11/docs/advanced/cast/custom.rst
index a779444c..8138cac6 100644
--- a/3rdparty/pybind11/docs/advanced/cast/custom.rst
+++ b/3rdparty/pybind11/docs/advanced/cast/custom.rst
@@ -26,7 +26,9 @@ The following Python snippet demonstrates the intended usage from the Python sid
def __int__(self):
return 123
+
from example import print
+
print(A())
To register the necessary conversion routines, it is necessary to add an
@@ -36,7 +38,7 @@ type is explicitly allowed.
.. code-block:: cpp
- namespace pybind11 { namespace detail {
+ namespace PYBIND11_NAMESPACE { namespace detail {
template <> struct type_caster<inty> {
public:
/**
@@ -44,7 +46,7 @@ type is explicitly allowed.
* function signatures and declares a local variable
* 'value' of type inty
*/
- PYBIND11_TYPE_CASTER(inty, _("inty"));
+ PYBIND11_TYPE_CASTER(inty, const_name("inty"));
/**
* Conversion part 1 (Python->C++): convert a PyObject into a inty
@@ -76,7 +78,7 @@ type is explicitly allowed.
return PyLong_FromLong(src.long_value);
}
};
- }} // namespace pybind11::detail
+ }} // namespace PYBIND11_NAMESPACE::detail
.. note::
diff --git a/3rdparty/pybind11/docs/advanced/cast/eigen.rst b/3rdparty/pybind11/docs/advanced/cast/eigen.rst
index e01472d5..a5c11a3f 100644
--- a/3rdparty/pybind11/docs/advanced/cast/eigen.rst
+++ b/3rdparty/pybind11/docs/advanced/cast/eigen.rst
@@ -52,7 +52,7 @@ can be mapped *and* if the numpy array is writeable (that is
the passed variable will be transparently carried out directly on the
``numpy.ndarray``.
-This means you can can write code such as the following and have it work as
+This means you can write code such as the following and have it work as
expected:
.. code-block:: cpp
@@ -112,7 +112,7 @@ example:
.. code-block:: python
a = MyClass()
- m = a.get_matrix() # flags.writeable = True, flags.owndata = False
+ m = a.get_matrix() # flags.writeable = True, flags.owndata = False
v = a.view_matrix() # flags.writeable = False, flags.owndata = False
c = a.copy_matrix() # flags.writeable = True, flags.owndata = True
# m[5,6] and v[5,6] refer to the same element, c[5,6] does not.
@@ -203,7 +203,7 @@ adding the ``order='F'`` option when creating an array:
.. code-block:: python
- myarray = np.array(source, order='F')
+ myarray = np.array(source, order="F")
Such an object will be passable to a bound function accepting an
``Eigen::Ref<MatrixXd>`` (or similar column-major Eigen type).
diff --git a/3rdparty/pybind11/docs/advanced/cast/overview.rst b/3rdparty/pybind11/docs/advanced/cast/overview.rst
index b0e32a52..011bd4c7 100644
--- a/3rdparty/pybind11/docs/advanced/cast/overview.rst
+++ b/3rdparty/pybind11/docs/advanced/cast/overview.rst
@@ -75,91 +75,96 @@ The following basic data types are supported out of the box (some may require
an additional extension header to be included). To pass other data structures
as arguments and return values, refer to the section on binding :ref:`classes`.
-+------------------------------------+---------------------------+-------------------------------+
-| Data type | Description | Header file |
-+====================================+===========================+===============================+
-| ``int8_t``, ``uint8_t`` | 8-bit integers | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``int16_t``, ``uint16_t`` | 16-bit integers | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``int32_t``, ``uint32_t`` | 32-bit integers | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``int64_t``, ``uint64_t`` | 64-bit integers | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``ssize_t``, ``size_t`` | Platform-dependent size | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``float``, ``double`` | Floating point types | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``bool`` | Two-state Boolean type | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``char`` | Character literal | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``char16_t`` | UTF-16 character literal | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``char32_t`` | UTF-32 character literal | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``wchar_t`` | Wide character literal | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``const char *`` | UTF-8 string literal | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``const char16_t *`` | UTF-16 string literal | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``const char32_t *`` | UTF-32 string literal | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``const wchar_t *`` | Wide string literal | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::string`` | STL dynamic UTF-8 string | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::u16string`` | STL dynamic UTF-16 string | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::u32string`` | STL dynamic UTF-32 string | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::wstring`` | STL dynamic wide string | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::string_view``, | STL C++17 string views | :file:`pybind11/pybind11.h` |
-| ``std::u16string_view``, etc. | | |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::pair<T1, T2>`` | Pair of two custom types | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::tuple<...>`` | Arbitrary tuple of types | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::reference_wrapper<...>`` | Reference type wrapper | :file:`pybind11/pybind11.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::complex<T>`` | Complex numbers | :file:`pybind11/complex.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::array<T, Size>`` | STL static array | :file:`pybind11/stl.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::vector<T>`` | STL dynamic array | :file:`pybind11/stl.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::deque<T>`` | STL double-ended queue | :file:`pybind11/stl.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::valarray<T>`` | STL value array | :file:`pybind11/stl.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::list<T>`` | STL linked list | :file:`pybind11/stl.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::map<T1, T2>`` | STL ordered map | :file:`pybind11/stl.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::unordered_map<T1, T2>`` | STL unordered map | :file:`pybind11/stl.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::set<T>`` | STL ordered set | :file:`pybind11/stl.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::unordered_set<T>`` | STL unordered set | :file:`pybind11/stl.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::optional<T>`` | STL optional type (C++17) | :file:`pybind11/stl.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::experimental::optional<T>`` | STL optional type (exp.) | :file:`pybind11/stl.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::variant<...>`` | Type-safe union (C++17) | :file:`pybind11/stl.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::function<...>`` | STL polymorphic function | :file:`pybind11/functional.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::chrono::duration<...>`` | STL time duration | :file:`pybind11/chrono.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``std::chrono::time_point<...>`` | STL date/time | :file:`pybind11/chrono.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``Eigen::Matrix<...>`` | Eigen: dense matrix | :file:`pybind11/eigen.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``Eigen::Map<...>`` | Eigen: mapped memory | :file:`pybind11/eigen.h` |
-+------------------------------------+---------------------------+-------------------------------+
-| ``Eigen::SparseMatrix<...>`` | Eigen: sparse matrix | :file:`pybind11/eigen.h` |
-+------------------------------------+---------------------------+-------------------------------+
++------------------------------------+---------------------------+-----------------------------------+
+| Data type | Description | Header file |
++====================================+===========================+===================================+
+| ``int8_t``, ``uint8_t`` | 8-bit integers | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``int16_t``, ``uint16_t`` | 16-bit integers | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``int32_t``, ``uint32_t`` | 32-bit integers | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``int64_t``, ``uint64_t`` | 64-bit integers | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``ssize_t``, ``size_t`` | Platform-dependent size | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``float``, ``double`` | Floating point types | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``bool`` | Two-state Boolean type | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``char`` | Character literal | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``char16_t`` | UTF-16 character literal | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``char32_t`` | UTF-32 character literal | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``wchar_t`` | Wide character literal | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``const char *`` | UTF-8 string literal | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``const char16_t *`` | UTF-16 string literal | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``const char32_t *`` | UTF-32 string literal | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``const wchar_t *`` | Wide string literal | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::string`` | STL dynamic UTF-8 string | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::u16string`` | STL dynamic UTF-16 string | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::u32string`` | STL dynamic UTF-32 string | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::wstring`` | STL dynamic wide string | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::string_view``, | STL C++17 string views | :file:`pybind11/pybind11.h` |
+| ``std::u16string_view``, etc. | | |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::pair<T1, T2>`` | Pair of two custom types | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::tuple<...>`` | Arbitrary tuple of types | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::reference_wrapper<...>`` | Reference type wrapper | :file:`pybind11/pybind11.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::complex<T>`` | Complex numbers | :file:`pybind11/complex.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::array<T, Size>`` | STL static array | :file:`pybind11/stl.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::vector<T>`` | STL dynamic array | :file:`pybind11/stl.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::deque<T>`` | STL double-ended queue | :file:`pybind11/stl.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::valarray<T>`` | STL value array | :file:`pybind11/stl.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::list<T>`` | STL linked list | :file:`pybind11/stl.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::map<T1, T2>`` | STL ordered map | :file:`pybind11/stl.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::unordered_map<T1, T2>`` | STL unordered map | :file:`pybind11/stl.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::set<T>`` | STL ordered set | :file:`pybind11/stl.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::unordered_set<T>`` | STL unordered set | :file:`pybind11/stl.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::optional<T>`` | STL optional type (C++17) | :file:`pybind11/stl.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::experimental::optional<T>`` | STL optional type (exp.) | :file:`pybind11/stl.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::variant<...>`` | Type-safe union (C++17) | :file:`pybind11/stl.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::filesystem::path<T>`` | STL path (C++17) [#]_ | :file:`pybind11/stl/filesystem.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::function<...>`` | STL polymorphic function | :file:`pybind11/functional.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::chrono::duration<...>`` | STL time duration | :file:`pybind11/chrono.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``std::chrono::time_point<...>`` | STL date/time | :file:`pybind11/chrono.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``Eigen::Matrix<...>`` | Eigen: dense matrix | :file:`pybind11/eigen.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``Eigen::Map<...>`` | Eigen: mapped memory | :file:`pybind11/eigen.h` |
++------------------------------------+---------------------------+-----------------------------------+
+| ``Eigen::SparseMatrix<...>`` | Eigen: sparse matrix | :file:`pybind11/eigen.h` |
++------------------------------------+---------------------------+-----------------------------------+
+
+.. [#] ``std::filesystem::path`` is converted to ``pathlib.Path`` and
+ ``os.PathLike`` is converted to ``std::filesystem::path``.
diff --git a/3rdparty/pybind11/docs/advanced/cast/stl.rst b/3rdparty/pybind11/docs/advanced/cast/stl.rst
index 70fde0d2..03d49b29 100644
--- a/3rdparty/pybind11/docs/advanced/cast/stl.rst
+++ b/3rdparty/pybind11/docs/advanced/cast/stl.rst
@@ -42,7 +42,7 @@ types:
.. code-block:: cpp
// `boost::optional` as an example -- can be any `std::optional`-like container
- namespace pybind11 { namespace detail {
+ namespace PYBIND11_NAMESPACE { namespace detail {
template <typename T>
struct type_caster<boost::optional<T>> : optional_caster<boost::optional<T>> {};
}}
@@ -54,7 +54,7 @@ for custom variant types:
.. code-block:: cpp
// `boost::variant` as an example -- can be any `std::variant`-like container
- namespace pybind11 { namespace detail {
+ namespace PYBIND11_NAMESPACE { namespace detail {
template <typename... Ts>
struct type_caster<boost::variant<Ts...>> : variant_caster<boost::variant<Ts...>> {};
@@ -66,18 +66,27 @@ for custom variant types:
return boost::apply_visitor(args...);
}
};
- }} // namespace pybind11::detail
+ }} // namespace PYBIND11_NAMESPACE::detail
The ``visit_helper`` specialization is not required if your ``name::variant`` provides
a ``name::visit()`` function. For any other function name, the specialization must be
included to tell pybind11 how to visit the variant.
+.. warning::
+
+ When converting a ``variant`` type, pybind11 follows the same rules as when
+ determining which function overload to call (:ref:`overload_resolution`), and
+ so the same caveats hold. In particular, the order in which the ``variant``'s
+ alternatives are listed is important, since pybind11 will try conversions in
+ this order. This means that, for example, when converting ``variant<int, bool>``,
+ the ``bool`` variant will never be selected, as any Python ``bool`` is already
+ an ``int`` and is convertible to a C++ ``int``. Changing the order of alternatives
+ (and using ``variant<bool, int>``, in this example) provides a solution.
+
.. note::
pybind11 only supports the modern implementation of ``boost::variant``
which makes use of variadic templates. This requires Boost 1.56 or newer.
- Additionally, on Windows, MSVC 2017 is required because ``boost::variant``
- falls back to the old non-variadic implementation on MSVC 2015.
.. _opaque:
diff --git a/3rdparty/pybind11/docs/advanced/cast/strings.rst b/3rdparty/pybind11/docs/advanced/cast/strings.rst
index e25701ec..e246c521 100644
--- a/3rdparty/pybind11/docs/advanced/cast/strings.rst
+++ b/3rdparty/pybind11/docs/advanced/cast/strings.rst
@@ -1,14 +1,6 @@
Strings, bytes and Unicode conversions
######################################
-.. note::
-
- This section discusses string handling in terms of Python 3 strings. For
- Python 2.7, replace all occurrences of ``str`` with ``unicode`` and
- ``bytes`` with ``str``. Python 2.7 users may find it best to use ``from
- __future__ import unicode_literals`` to avoid unintentionally using ``str``
- instead of ``unicode``.
-
Passing Python strings to C++
=============================
@@ -36,13 +28,13 @@ everywhere <http://utf8everywhere.org/>`_.
}
);
-.. code-block:: python
+.. code-block:: pycon
- >>> utf8_test('🎂')
+ >>> utf8_test("🎂")
utf-8 is icing on the cake.
🎂
- >>> utf8_charptr('🍕')
+ >>> utf8_charptr("🍕")
My favorite food is
🍕
@@ -58,9 +50,9 @@ Passing bytes to C++
--------------------
A Python ``bytes`` object will be passed to C++ functions that accept
-``std::string`` or ``char*`` *without* conversion. On Python 3, in order to
-make a function *only* accept ``bytes`` (and not ``str``), declare it as taking
-a ``py::bytes`` argument.
+``std::string`` or ``char*`` *without* conversion. In order to make a function
+*only* accept ``bytes`` (and not ``str``), declare it as taking a ``py::bytes``
+argument.
Returning C++ strings to Python
@@ -80,7 +72,7 @@ raise a ``UnicodeDecodeError``.
}
);
-.. code-block:: python
+.. code-block:: pycon
>>> isinstance(example.std_string_return(), str)
True
@@ -114,7 +106,7 @@ conversion has the same overhead as implicit conversion.
}
);
-.. code-block:: python
+.. code-block:: pycon
>>> str_output()
'Send your résumé to Alice in HR'
@@ -143,7 +135,7 @@ returned to Python as ``bytes``, then one can return the data as a
}
);
-.. code-block:: python
+.. code-block:: pycon
>>> example.return_bytes()
b'\xba\xd0\xba\xd0'
@@ -160,7 +152,7 @@ encoding, but cannot convert ``std::string`` back to ``bytes`` implicitly.
}
);
-.. code-block:: python
+.. code-block:: pycon
>>> isinstance(example.asymmetry(b"have some bytes"), str)
True
@@ -204,11 +196,6 @@ decoded to Python ``str``.
}
);
-.. warning::
-
- Wide character strings may not work as described on Python 2.7 or Python
- 3.3 compiled with ``--enable-unicode=ucs2``.
-
Strings in multibyte encodings such as Shift-JIS must transcoded to a
UTF-8/16/32 before being returned to Python.
@@ -229,16 +216,16 @@ character.
m.def("pass_char", [](char c) { return c; });
m.def("pass_wchar", [](wchar_t w) { return w; });
-.. code-block:: python
+.. code-block:: pycon
- >>> example.pass_char('A')
+ >>> example.pass_char("A")
'A'
While C++ will cast integers to character types (``char c = 0x65;``), pybind11
does not convert Python integers to characters implicitly. The Python function
``chr()`` can be used to convert integers to characters.
-.. code-block:: python
+.. code-block:: pycon
>>> example.pass_char(0x65)
TypeError
@@ -259,17 +246,17 @@ a combining acute accent). The combining character will be lost if the
two-character sequence is passed as an argument, even though it renders as a
single grapheme.
-.. code-block:: python
+.. code-block:: pycon
- >>> example.pass_wchar('é')
+ >>> example.pass_wchar("é")
'é'
- >>> combining_e_acute = 'e' + '\u0301'
+ >>> combining_e_acute = "e" + "\u0301"
>>> combining_e_acute
'é'
- >>> combining_e_acute == 'é'
+ >>> combining_e_acute == "é"
False
>>> example.pass_wchar(combining_e_acute)
@@ -278,9 +265,9 @@ single grapheme.
Normalizing combining characters before passing the character literal to C++
may resolve *some* of these issues:
-.. code-block:: python
+.. code-block:: pycon
- >>> example.pass_wchar(unicodedata.normalize('NFC', combining_e_acute))
+ >>> example.pass_wchar(unicodedata.normalize("NFC", combining_e_acute))
'é'
In some languages (Thai for example), there are `graphemes that cannot be
diff --git a/3rdparty/pybind11/docs/advanced/classes.rst b/3rdparty/pybind11/docs/advanced/classes.rst
index 49279020..01a490b7 100644
--- a/3rdparty/pybind11/docs/advanced/classes.rst
+++ b/3rdparty/pybind11/docs/advanced/classes.rst
@@ -9,7 +9,7 @@ that you are already familiar with the basics from :doc:`/classes`.
Overriding virtual functions in Python
======================================
-Suppose that a C++ class or interface has a virtual function that we'd like to
+Suppose that a C++ class or interface has a virtual function that we'd like
to override from within Python (we'll focus on the class ``Animal``; ``Dog`` is
given as a specific example of how one would do this with traditional C++
code).
@@ -133,14 +133,14 @@ a virtual method call.
>>> from example import *
>>> d = Dog()
>>> call_go(d)
- u'woof! woof! woof! '
+ 'woof! woof! woof! '
>>> class Cat(Animal):
... def go(self, n_times):
- ... return "meow! " * n_times
+ ... return "meow! " * n_times
...
>>> c = Cat()
>>> call_go(c)
- u'meow! meow! meow! '
+ 'meow! meow! meow! '
If you are defining a custom constructor in a derived Python class, you *must*
ensure that you explicitly call the bound C++ constructor using ``__init__``,
@@ -159,8 +159,9 @@ Here is an example:
class Dachshund(Dog):
def __init__(self, name):
- Dog.__init__(self) # Without this, a TypeError is raised.
+ Dog.__init__(self) # Without this, a TypeError is raised.
self.name = name
+
def bark(self):
return "yap!"
@@ -259,7 +260,7 @@ override the ``name()`` method):
.. note::
- Note the trailing commas in the ``PYBIND11_OVERIDE`` calls to ``name()``
+ Note the trailing commas in the ``PYBIND11_OVERRIDE`` calls to ``name()``
and ``bark()``. These are needed to portably implement a trampoline for a
function that does not take any arguments. For functions that take
a nonzero number of arguments, the trailing comma must be omitted.
@@ -804,7 +805,7 @@ to bind these two functions:
}
));
-The ``__setstate__`` part of the ``py::picke()`` definition follows the same
+The ``__setstate__`` part of the ``py::pickle()`` definition follows the same
rules as the single-argument version of ``py::init()``. The return type can be
a value, pointer or holder type. See :ref:`custom_constructors` for details.
@@ -812,26 +813,21 @@ An instance can now be pickled as follows:
.. code-block:: python
- try:
- import cPickle as pickle # Use cPickle on Python 2.7
- except ImportError:
- import pickle
+ import pickle
p = Pickleable("test_value")
p.setExtra(15)
- data = pickle.dumps(p, 2)
+ data = pickle.dumps(p)
.. note::
- Note that only the cPickle module is supported on Python 2.7.
-
- The second argument to ``dumps`` is also crucial: it selects the pickle
- protocol version 2, since the older version 1 is not supported. Newer
- versions are also fine—for instance, specify ``-1`` to always use the
- latest available version. Beware: failure to follow these instructions
- will cause important pybind11 memory allocation routines to be skipped
- during unpickling, which will likely lead to memory corruption and/or
- segmentation faults.
+ If given, the second argument to ``dumps`` must be 2 or larger - 0 and 1 are
+ not supported. Newer versions are also fine; for instance, specify ``-1`` to
+ always use the latest available version. Beware: failure to follow these
+ instructions will cause important pybind11 memory allocation routines to be
+ skipped during unpickling, which will likely lead to memory corruption
+ and/or segmentation faults. Python defaults to version 3 (Python 3-3.7) and
+ version 4 for Python 3.8+.
.. seealso::
@@ -848,11 +844,9 @@ Python normally uses references in assignments. Sometimes a real copy is needed
to prevent changing all copies. The ``copy`` module [#f5]_ provides these
capabilities.
-On Python 3, a class with pickle support is automatically also (deep)copy
+A class with pickle support is automatically also (deep)copy
compatible. However, performance can be improved by adding custom
-``__copy__`` and ``__deepcopy__`` methods. With Python 2.7, these custom methods
-are mandatory for (deep)copy compatibility, because pybind11 only supports
-cPickle.
+``__copy__`` and ``__deepcopy__`` methods.
For simple classes (deep)copy can be enabled by using the copy constructor,
which should look as follows:
@@ -1124,13 +1118,6 @@ described trampoline:
py::class_<A, Trampoline>(m, "A") // <-- `Trampoline` here
.def("foo", &Publicist::foo); // <-- `Publicist` here, not `Trampoline`!
-.. note::
-
- MSVC 2015 has a compiler bug (fixed in version 2017) which
- requires a more explicit function binding in the form of
- ``.def("foo", static_cast<int (A::*)() const>(&Publicist::foo));``
- where ``int (A::*)() const`` is the type of ``A::foo``.
-
Binding final classes
=====================
@@ -1153,12 +1140,65 @@ error:
>>> class PyFinalChild(IsFinal):
... pass
+ ...
TypeError: type 'IsFinal' is not an acceptable base type
.. note:: This attribute is currently ignored on PyPy
.. versionadded:: 2.6
+Binding classes with template parameters
+========================================
+
+pybind11 can also wrap classes that have template parameters. Consider these classes:
+
+.. code-block:: cpp
+
+ struct Cat {};
+ struct Dog {};
+
+ template <typename PetType>
+ struct Cage {
+ Cage(PetType& pet);
+ PetType& get();
+ };
+
+C++ templates may only be instantiated at compile time, so pybind11 can only
+wrap instantiated templated classes. You cannot wrap a non-instantiated template:
+
+.. code-block:: cpp
+
+ // BROKEN (this will not compile)
+ py::class_<Cage>(m, "Cage");
+ .def("get", &Cage::get);
+
+You must explicitly specify each template/type combination that you want to
+wrap separately.
+
+.. code-block:: cpp
+
+ // ok
+ py::class_<Cage<Cat>>(m, "CatCage")
+ .def("get", &Cage<Cat>::get);
+
+ // ok
+ py::class_<Cage<Dog>>(m, "DogCage")
+ .def("get", &Cage<Dog>::get);
+
+If your class methods have template parameters you can wrap those as well,
+but once again each instantiation must be explicitly specified:
+
+.. code-block:: cpp
+
+ typename <typename T>
+ struct MyClass {
+ template <typename V>
+ T fn(V v);
+ };
+
+ py::class<MyClass<int>>(m, "MyClassT")
+ .def("fn", &MyClass<int>::fn<std::string>);
+
Custom automatic downcasters
============================
@@ -1188,7 +1228,7 @@ whether a downcast is safe, you can proceed by specializing the
std::string bark() const { return sound; }
};
- namespace pybind11 {
+ namespace PYBIND11_NAMESPACE {
template<> struct polymorphic_type_hook<Pet> {
static const void *get(const Pet *src, const std::type_info*& type) {
// note that src may be nullptr
@@ -1199,7 +1239,7 @@ whether a downcast is safe, you can proceed by specializing the
return src;
}
};
- } // namespace pybind11
+ } // namespace PYBIND11_NAMESPACE
When pybind11 wants to convert a C++ pointer of type ``Base*`` to a
Python object, it calls ``polymorphic_type_hook<Base>::get()`` to
@@ -1247,7 +1287,7 @@ Accessing the type object
You can get the type object from a C++ class that has already been registered using:
-.. code-block:: python
+.. code-block:: cpp
py::type T_py = py::type::of<T>();
@@ -1259,3 +1299,37 @@ object, just like ``type(ob)`` in Python.
Other types, like ``py::type::of<int>()``, do not work, see :ref:`type-conversions`.
.. versionadded:: 2.6
+
+Custom type setup
+=================
+
+For advanced use cases, such as enabling garbage collection support, you may
+wish to directly manipulate the ``PyHeapTypeObject`` corresponding to a
+``py::class_`` definition.
+
+You can do that using ``py::custom_type_setup``:
+
+.. code-block:: cpp
+
+ struct OwnsPythonObjects {
+ py::object value = py::none();
+ };
+ py::class_<OwnsPythonObjects> cls(
+ m, "OwnsPythonObjects", py::custom_type_setup([](PyHeapTypeObject *heap_type) {
+ auto *type = &heap_type->ht_type;
+ type->tp_flags |= Py_TPFLAGS_HAVE_GC;
+ type->tp_traverse = [](PyObject *self_base, visitproc visit, void *arg) {
+ auto &self = py::cast<OwnsPythonObjects&>(py::handle(self_base));
+ Py_VISIT(self.value.ptr());
+ return 0;
+ };
+ type->tp_clear = [](PyObject *self_base) {
+ auto &self = py::cast<OwnsPythonObjects&>(py::handle(self_base));
+ self.value = py::none();
+ return 0;
+ };
+ }));
+ cls.def(py::init<>());
+ cls.def_readwrite("value", &OwnsPythonObjects::value);
+
+.. versionadded:: 2.8
diff --git a/3rdparty/pybind11/docs/advanced/embedding.rst b/3rdparty/pybind11/docs/advanced/embedding.rst
index dfdaad2d..dd980d48 100644
--- a/3rdparty/pybind11/docs/advanced/embedding.rst
+++ b/3rdparty/pybind11/docs/advanced/embedding.rst
@@ -40,15 +40,15 @@ The essential structure of the ``main.cpp`` file looks like this:
}
The interpreter must be initialized before using any Python API, which includes
-all the functions and classes in pybind11. The RAII guard class `scoped_interpreter`
+all the functions and classes in pybind11. The RAII guard class ``scoped_interpreter``
takes care of the interpreter lifetime. After the guard is destroyed, the interpreter
shuts down and clears its memory. No Python functions can be called after this.
Executing Python code
=====================
-There are a few different ways to run Python code. One option is to use `eval`,
-`exec` or `eval_file`, as explained in :ref:`eval`. Here is a quick example in
+There are a few different ways to run Python code. One option is to use ``eval``,
+``exec`` or ``eval_file``, as explained in :ref:`eval`. Here is a quick example in
the context of an executable with an embedded interpreter:
.. code-block:: cpp
@@ -108,7 +108,7 @@ The two approaches can also be combined:
Importing modules
=================
-Python modules can be imported using `module_::import()`:
+Python modules can be imported using ``module_::import()``:
.. code-block:: cpp
@@ -122,6 +122,7 @@ embedding the interpreter. This makes it easy to import local Python files:
"""calc.py located in the working directory"""
+
def add(i, j):
return i + j
@@ -133,7 +134,7 @@ embedding the interpreter. This makes it easy to import local Python files:
int n = result.cast<int>();
assert(n == 3);
-Modules can be reloaded using `module_::reload()` if the source is modified e.g.
+Modules can be reloaded using ``module_::reload()`` if the source is modified e.g.
by an external process. This can be useful in scenarios where the application
imports a user defined data processing script which needs to be updated after
changes by the user. Note that this function does not reload modules recursively.
@@ -143,7 +144,7 @@ changes by the user. Note that this function does not reload modules recursively
Adding embedded modules
=======================
-Embedded binary modules can be added using the `PYBIND11_EMBEDDED_MODULE` macro.
+Embedded binary modules can be added using the ``PYBIND11_EMBEDDED_MODULE`` macro.
Note that the definition must be placed at global scope. They can be imported
like any other module.
@@ -169,7 +170,7 @@ like any other module.
Unlike extension modules where only a single binary module can be created, on
the embedded side an unlimited number of modules can be added using multiple
-`PYBIND11_EMBEDDED_MODULE` definitions (as long as they have unique names).
+``PYBIND11_EMBEDDED_MODULE`` definitions (as long as they have unique names).
These modules are added to Python's list of builtins, so they can also be
imported in pure Python files loaded by the interpreter. Everything interacts
@@ -215,9 +216,9 @@ naturally:
Interpreter lifetime
====================
-The Python interpreter shuts down when `scoped_interpreter` is destroyed. After
+The Python interpreter shuts down when ``scoped_interpreter`` is destroyed. After
this, creating a new instance will restart the interpreter. Alternatively, the
-`initialize_interpreter` / `finalize_interpreter` pair of functions can be used
+``initialize_interpreter`` / ``finalize_interpreter`` pair of functions can be used
to directly set the state at any time.
Modules created with pybind11 can be safely re-initialized after the interpreter
@@ -229,8 +230,8 @@ global data. All the details can be found in the CPython documentation.
.. warning::
- Creating two concurrent `scoped_interpreter` guards is a fatal error. So is
- calling `initialize_interpreter` for a second time after the interpreter
+ Creating two concurrent ``scoped_interpreter`` guards is a fatal error. So is
+ calling ``initialize_interpreter`` for a second time after the interpreter
has already been initialized.
Do not use the raw CPython API functions ``Py_Initialize`` and
@@ -241,7 +242,7 @@ global data. All the details can be found in the CPython documentation.
Sub-interpreter support
=======================
-Creating multiple copies of `scoped_interpreter` is not possible because it
+Creating multiple copies of ``scoped_interpreter`` is not possible because it
represents the main Python interpreter. Sub-interpreters are something different
and they do permit the existence of multiple interpreters. This is an advanced
feature of the CPython API and should be handled with care. pybind11 does not
@@ -257,5 +258,5 @@ We'll just mention a couple of caveats the sub-interpreters support in pybind11:
2. Managing multiple threads, multiple interpreters and the GIL can be
challenging and there are several caveats here, even within the pure
CPython API (please refer to the Python docs for details). As for
- pybind11, keep in mind that `gil_scoped_release` and `gil_scoped_acquire`
+ pybind11, keep in mind that ``gil_scoped_release`` and ``gil_scoped_acquire``
do not take sub-interpreters into account.
diff --git a/3rdparty/pybind11/docs/advanced/exceptions.rst b/3rdparty/pybind11/docs/advanced/exceptions.rst
index 5eae5562..2211caf5 100644
--- a/3rdparty/pybind11/docs/advanced/exceptions.rst
+++ b/3rdparty/pybind11/docs/advanced/exceptions.rst
@@ -43,18 +43,28 @@ at its exception handler.
| | of bounds access in ``__getitem__``, |
| | ``__setitem__``, etc.) |
+--------------------------------------+--------------------------------------+
-| :class:`pybind11::value_error` | ``ValueError`` (used to indicate |
-| | wrong value passed in |
-| | ``container.remove(...)``) |
-+--------------------------------------+--------------------------------------+
| :class:`pybind11::key_error` | ``KeyError`` (used to indicate out |
| | of bounds access in ``__getitem__``, |
| | ``__setitem__`` in dict-like |
| | objects, etc.) |
+--------------------------------------+--------------------------------------+
+| :class:`pybind11::value_error` | ``ValueError`` (used to indicate |
+| | wrong value passed in |
+| | ``container.remove(...)``) |
++--------------------------------------+--------------------------------------+
+| :class:`pybind11::type_error` | ``TypeError`` |
++--------------------------------------+--------------------------------------+
+| :class:`pybind11::buffer_error` | ``BufferError`` |
++--------------------------------------+--------------------------------------+
+| :class:`pybind11::import_error` | ``ImportError`` |
++--------------------------------------+--------------------------------------+
+| :class:`pybind11::attribute_error` | ``AttributeError`` |
++--------------------------------------+--------------------------------------+
+| Any other exception | ``RuntimeError`` |
++--------------------------------------+--------------------------------------+
Exception translation is not bidirectional. That is, *catching* the C++
-exceptions defined above above will not trap exceptions that originate from
+exceptions defined above will not trap exceptions that originate from
Python. For that, catch :class:`pybind11::error_already_set`. See :ref:`below
<handling_python_exceptions_cpp>` for further details.
@@ -67,9 +77,10 @@ Registering custom translators
If the default exception conversion policy described above is insufficient,
pybind11 also provides support for registering custom exception translators.
-To register a simple exception conversion that translates a C++ exception into
-a new Python exception using the C++ exception's ``what()`` method, a helper
-function is available:
+Similar to pybind11 classes, exception translators can be local to the module
+they are defined in or global to the entire python session. To register a simple
+exception conversion that translates a C++ exception into a new Python exception
+using the C++ exception's ``what()`` method, a helper function is available:
.. code-block:: cpp
@@ -79,29 +90,39 @@ This call creates a Python exception class with the name ``PyExp`` in the given
module and automatically converts any encountered exceptions of type ``CppExp``
into Python exceptions of type ``PyExp``.
+A matching function is available for registering a local exception translator:
+
+.. code-block:: cpp
+
+ py::register_local_exception<CppExp>(module, "PyExp");
+
+
It is possible to specify base class for the exception using the third
-parameter, a `handle`:
+parameter, a ``handle``:
.. code-block:: cpp
py::register_exception<CppExp>(module, "PyExp", PyExc_RuntimeError);
+ py::register_local_exception<CppExp>(module, "PyExp", PyExc_RuntimeError);
-Then `PyExp` can be caught both as `PyExp` and `RuntimeError`.
+Then ``PyExp`` can be caught both as ``PyExp`` and ``RuntimeError``.
The class objects of the built-in Python exceptions are listed in the Python
documentation on `Standard Exceptions <https://docs.python.org/3/c-api/exceptions.html#standard-exceptions>`_.
-The default base class is `PyExc_Exception`.
+The default base class is ``PyExc_Exception``.
-When more advanced exception translation is needed, the function
-``py::register_exception_translator(translator)`` can be used to register
+When more advanced exception translation is needed, the functions
+``py::register_exception_translator(translator)`` and
+``py::register_local_exception_translator(translator)`` can be used to register
functions that can translate arbitrary exception types (and which may include
-additional logic to do so). The function takes a stateless callable (e.g. a
+additional logic to do so). The functions takes a stateless callable (e.g. a
function pointer or a lambda function without captured variables) with the call
signature ``void(std::exception_ptr)``.
When a C++ exception is thrown, the registered exception translators are tried
in reverse order of registration (i.e. the last registered translator gets the
-first shot at handling the exception).
+first shot at handling the exception). All local translators will be tried
+before a global translator is tried.
Inside the translator, ``std::rethrow_exception`` should be used within
a try block to re-throw the exception. One or more catch clauses to catch
@@ -156,6 +177,57 @@ section.
may be explicitly (re-)thrown to delegate it to the other,
previously-declared existing exception translators.
+ Note that ``libc++`` and ``libstdc++`` `behave differently <https://stackoverflow.com/questions/19496643/using-clang-fvisibility-hidden-and-typeinfo-and-type-erasure/28827430>`_
+ with ``-fvisibility=hidden``. Therefore exceptions that are used across ABI boundaries need to be explicitly exported, as exercised in ``tests/test_exceptions.h``.
+ See also: "Problems with C++ exceptions" under `GCC Wiki <https://gcc.gnu.org/wiki/Visibility>`_.
+
+
+Local vs Global Exception Translators
+=====================================
+
+When a global exception translator is registered, it will be applied across all
+modules in the reverse order of registration. This can create behavior where the
+order of module import influences how exceptions are translated.
+
+If module1 has the following translator:
+
+.. code-block:: cpp
+
+ py::register_exception_translator([](std::exception_ptr p) {
+ try {
+ if (p) std::rethrow_exception(p);
+ } catch (const std::invalid_argument &e) {
+ PyErr_SetString("module1 handled this")
+ }
+ }
+
+and module2 has the following similar translator:
+
+.. code-block:: cpp
+
+ py::register_exception_translator([](std::exception_ptr p) {
+ try {
+ if (p) std::rethrow_exception(p);
+ } catch (const std::invalid_argument &e) {
+ PyErr_SetString("module2 handled this")
+ }
+ }
+
+then which translator handles the invalid_argument will be determined by the
+order that module1 and module2 are imported. Since exception translators are
+applied in the reverse order of registration, which ever module was imported
+last will "win" and that translator will be applied.
+
+If there are multiple pybind11 modules that share exception types (either
+standard built-in or custom) loaded into a single python instance and
+consistent error handling behavior is needed, then local translators should be
+used.
+
+Changing the previous example to use ``register_local_exception_translator``
+would mean that when invalid_argument is thrown in the module2 code, the
+module2 translator will always handle it, while in module1, the module1
+translator will do the same.
+
.. _handling_python_exceptions_cpp:
Handling exceptions from Python in C++
@@ -188,7 +260,7 @@ For example:
} catch (py::error_already_set &e) {
if (e.matches(PyExc_FileNotFoundError)) {
py::print("missing.txt not found");
- } else if (e.match(PyExc_PermissionError)) {
+ } else if (e.matches(PyExc_PermissionError)) {
py::print("missing.txt found but not accessible");
} else {
throw;
@@ -253,6 +325,34 @@ Alternately, to ignore the error, call `PyErr_Clear
Any Python error must be thrown or cleared, or Python/pybind11 will be left in
an invalid state.
+Chaining exceptions ('raise from')
+==================================
+
+Python has a mechanism for indicating that exceptions were caused by other
+exceptions:
+
+.. code-block:: py
+
+ try:
+ print(1 / 0)
+ except Exception as exc:
+ raise RuntimeError("could not divide by zero") from exc
+
+To do a similar thing in pybind11, you can use the ``py::raise_from`` function. It
+sets the current python error indicator, so to continue propagating the exception
+you should ``throw py::error_already_set()``.
+
+.. code-block:: cpp
+
+ try {
+ py::eval("print(1 / 0"));
+ } catch (py::error_already_set &e) {
+ py::raise_from(e, PyExc_RuntimeError, "could not divide by zero");
+ throw py::error_already_set();
+ }
+
+.. versionadded:: 2.8
+
.. _unraisable_exceptions:
Handling unraisable exceptions
diff --git a/3rdparty/pybind11/docs/advanced/functions.rst b/3rdparty/pybind11/docs/advanced/functions.rst
index ebdff9c9..69e3d8a1 100644
--- a/3rdparty/pybind11/docs/advanced/functions.rst
+++ b/3rdparty/pybind11/docs/advanced/functions.rst
@@ -50,7 +50,7 @@ implied transfer of ownership, i.e.:
.. code-block:: cpp
- m.def("get_data", &get_data, return_value_policy::reference);
+ m.def("get_data", &get_data, py::return_value_policy::reference);
On the other hand, this is not the right policy for many other situations,
where ignoring ownership could lead to resource leaks.
@@ -90,17 +90,18 @@ The following table provides an overview of available policies:
| | return value is referenced by Python. This is the default policy for |
| | property getters created via ``def_property``, ``def_readwrite``, etc. |
+--------------------------------------------------+----------------------------------------------------------------------------+
-| :enum:`return_value_policy::automatic` | **Default policy.** This policy falls back to the policy |
+| :enum:`return_value_policy::automatic` | This policy falls back to the policy |
| | :enum:`return_value_policy::take_ownership` when the return value is a |
| | pointer. Otherwise, it uses :enum:`return_value_policy::move` or |
| | :enum:`return_value_policy::copy` for rvalue and lvalue references, |
| | respectively. See above for a description of what all of these different |
-| | policies do. |
+| | policies do. This is the default policy for ``py::class_``-wrapped types. |
+--------------------------------------------------+----------------------------------------------------------------------------+
| :enum:`return_value_policy::automatic_reference` | As above, but use policy :enum:`return_value_policy::reference` when the |
| | return value is a pointer. This is the default conversion policy for |
| | function arguments when calling Python functions manually from C++ code |
-| | (i.e. via handle::operator()). You probably won't need to use this. |
+| | (i.e. via ``handle::operator()``) and the casters in ``pybind11/stl.h``. |
+| | You probably won't need to use this explicitly. |
+--------------------------------------------------+----------------------------------------------------------------------------+
Return value policies can also be applied to properties:
@@ -119,7 +120,7 @@ targeted arguments can be passed through the :class:`cpp_function` constructor:
.. code-block:: cpp
class_<MyClass>(m, "MyClass")
- .def_property("data"
+ .def_property("data",
py::cpp_function(&MyClass::getData, py::return_value_policy::copy),
py::cpp_function(&MyClass::setData)
);
@@ -182,6 +183,9 @@ relies on the ability to create a *weak reference* to the nurse object. When
the nurse object is not a pybind11-registered type and does not support weak
references, an exception will be thrown.
+If you use an incorrect argument index, you will get a ``RuntimeError`` saying
+``Could not activate keep_alive!``. You should review the indices you're using.
+
Consider the following example: here, the binding code for a list append
operation ties the lifetime of the newly added element to the underlying
container:
@@ -228,7 +232,7 @@ is equivalent to the following pseudocode:
});
The only requirement is that ``T`` is default-constructible, but otherwise any
-scope guard will work. This is very useful in combination with `gil_scoped_release`.
+scope guard will work. This is very useful in combination with ``gil_scoped_release``.
See :ref:`gil`.
Multiple guards can also be specified as ``py::call_guard<T1, T2, T3...>``. The
@@ -251,7 +255,7 @@ For instance, the following statement iterates over a Python ``dict``:
.. code-block:: cpp
- void print_dict(py::dict dict) {
+ void print_dict(const py::dict& dict) {
/* Easily interact with Python types */
for (auto item : dict)
std::cout << "key=" << std::string(py::str(item.first)) << ", "
@@ -268,7 +272,7 @@ And used in Python as usual:
.. code-block:: pycon
- >>> print_dict({'foo': 123, 'bar': 'hello'})
+ >>> print_dict({"foo": 123, "bar": "hello"})
key=foo, value=123
key=bar, value=hello
@@ -289,7 +293,7 @@ Such functions can also be created using pybind11:
.. code-block:: cpp
- void generic(py::args args, py::kwargs kwargs) {
+ void generic(py::args args, const py::kwargs& kwargs) {
/// .. do something with args
if (kwargs)
/// .. do something with kwargs
@@ -302,8 +306,9 @@ The class ``py::args`` derives from ``py::tuple`` and ``py::kwargs`` derives
from ``py::dict``.
You may also use just one or the other, and may combine these with other
-arguments as long as the ``py::args`` and ``py::kwargs`` arguments are the last
-arguments accepted by the function.
+arguments. Note, however, that ``py::kwargs`` must always be the last argument
+of the function, and ``py::args`` implies that any further arguments are
+keyword-only (see :ref:`keyword_only_arguments`).
Please refer to the other examples for details on how to iterate over these,
and on how to cast their entries into C++ objects. A demonstration is also
@@ -362,10 +367,12 @@ like so:
py::class_<MyClass>("MyClass")
.def("myFunction", py::arg("arg") = static_cast<SomeType *>(nullptr));
+.. _keyword_only_arguments:
+
Keyword-only arguments
======================
-Python 3 introduced keyword-only arguments by specifying an unnamed ``*``
+Python implements keyword-only arguments by specifying an unnamed ``*``
argument in a function definition:
.. code-block:: python
@@ -373,10 +380,11 @@ argument in a function definition:
def f(a, *, b): # a can be positional or via keyword; b must be via keyword
pass
+
f(a=1, b=2) # good
f(b=2, a=1) # good
- f(1, b=2) # good
- f(1, 2) # TypeError: f() takes 1 positional argument but 2 were given
+ f(1, b=2) # good
+ f(1, 2) # TypeError: f() takes 1 positional argument but 2 were given
Pybind11 provides a ``py::kw_only`` object that allows you to implement
the same behaviour by specifying the object between positional and keyword-only
@@ -387,11 +395,19 @@ argument annotations when registering the function:
m.def("f", [](int a, int b) { /* ... */ },
py::arg("a"), py::kw_only(), py::arg("b"));
-Note that you currently cannot combine this with a ``py::args`` argument. This
-feature does *not* require Python 3 to work.
-
.. versionadded:: 2.6
+A ``py::args`` argument implies that any following arguments are keyword-only,
+as if ``py::kw_only()`` had been specified in the same relative location of the
+argument list as the ``py::args`` argument. The ``py::kw_only()`` may be
+included to be explicit about this, but is not required.
+
+.. versionchanged:: 2.9
+ This can now be combined with ``py::args``. Before, ``py::args`` could only
+ occur at the end of the argument list, or immediately before a ``py::kwargs``
+ argument at the end.
+
+
Positional-only arguments
=========================
@@ -524,6 +540,8 @@ The default behaviour when the tag is unspecified is to allow ``None``.
not allow ``None`` as argument. To pass optional argument of these copied types consider
using ``std::optional<T>``
+.. _overload_resolution:
+
Overload resolution order
=========================
@@ -559,3 +577,38 @@ prefers earlier-defined overloads to later-defined ones.
.. versionadded:: 2.6
The ``py::prepend()`` tag.
+
+Binding functions with template parameters
+==========================================
+
+You can bind functions that have template parameters. Here's a function:
+
+.. code-block:: cpp
+
+ template <typename T>
+ void set(T t);
+
+C++ templates cannot be instantiated at runtime, so you cannot bind the
+non-instantiated function:
+
+.. code-block:: cpp
+
+ // BROKEN (this will not compile)
+ m.def("set", &set);
+
+You must bind each instantiated function template separately. You may bind
+each instantiation with the same name, which will be treated the same as
+an overloaded function:
+
+.. code-block:: cpp
+
+ m.def("set", &set<int>);
+ m.def("set", &set<std::string>);
+
+Sometimes it's more clear to bind them with separate names, which is also
+an option:
+
+.. code-block:: cpp
+
+ m.def("setInt", &set<int>);
+ m.def("setString", &set<std::string>);
diff --git a/3rdparty/pybind11/docs/advanced/misc.rst b/3rdparty/pybind11/docs/advanced/misc.rst
index b3f3b226..edab15fc 100644
--- a/3rdparty/pybind11/docs/advanced/misc.rst
+++ b/3rdparty/pybind11/docs/advanced/misc.rst
@@ -84,7 +84,7 @@ could be realized as follows (important changes highlighted):
});
}
-The ``call_go`` wrapper can also be simplified using the `call_guard` policy
+The ``call_go`` wrapper can also be simplified using the ``call_guard`` policy
(see :ref:`call_policies`) which yields the same result:
.. code-block:: cpp
diff --git a/3rdparty/pybind11/docs/advanced/pycpp/numpy.rst b/3rdparty/pybind11/docs/advanced/pycpp/numpy.rst
index 19ed10b3..07c96930 100644
--- a/3rdparty/pybind11/docs/advanced/pycpp/numpy.rst
+++ b/3rdparty/pybind11/docs/advanced/pycpp/numpy.rst
@@ -87,7 +87,7 @@ buffer objects (e.g. a NumPy matrix).
/* Request a buffer descriptor from Python */
py::buffer_info info = b.request();
- /* Some sanity checks ... */
+ /* Some basic validation checks ... */
if (info.format != py::format_descriptor<Scalar>::format())
throw std::runtime_error("Incompatible format: expected a double array!");
@@ -150,8 +150,10 @@ NumPy array containing double precision values.
When it is invoked with a different type (e.g. an integer or a list of
integers), the binding code will attempt to cast the input into a NumPy array
-of the requested type. Note that this feature requires the
-:file:`pybind11/numpy.h` header to be included.
+of the requested type. This feature requires the :file:`pybind11/numpy.h`
+header to be included. Note that :file:`pybind11/numpy.h` does not depend on
+the NumPy headers, and thus can be used without declaring a build-time
+dependency on NumPy; NumPy>=1.7.0 is a runtime dependency.
Data in NumPy arrays is not guaranteed to packed in a dense manner;
furthermore, entries can be separated by arbitrary column and row strides.
@@ -169,6 +171,31 @@ template parameter, and it ensures that non-conforming arguments are converted
into an array satisfying the specified requirements instead of trying the next
function overload.
+There are several methods on arrays; the methods listed below under references
+work, as well as the following functions based on the NumPy API:
+
+- ``.dtype()`` returns the type of the contained values.
+
+- ``.strides()`` returns a pointer to the strides of the array (optionally pass
+ an integer axis to get a number).
+
+- ``.flags()`` returns the flag settings. ``.writable()`` and ``.owndata()``
+ are directly available.
+
+- ``.offset_at()`` returns the offset (optionally pass indices).
+
+- ``.squeeze()`` returns a view with length-1 axes removed.
+
+- ``.view(dtype)`` returns a view of the array with a different dtype.
+
+- ``.reshape({i, j, ...})`` returns a view of the array with a different shape.
+ ``.resize({...})`` is also available.
+
+- ``.index_at(i, j, ...)`` gets the count from the beginning to a given index.
+
+
+There are also several methods for getting references (described below).
+
Structured types
================
@@ -231,8 +258,8 @@ by the compiler. The result is returned as a NumPy array of type
.. code-block:: pycon
- >>> x = np.array([[1, 3],[5, 7]])
- >>> y = np.array([[2, 4],[6, 8]])
+ >>> x = np.array([[1, 3], [5, 7]])
+ >>> y = np.array([[2, 4], [6, 8]])
>>> z = 3
>>> result = vectorized_func(x, y, z)
@@ -343,21 +370,21 @@ The returned proxy object supports some of the same methods as ``py::array`` so
that it can be used as a drop-in replacement for some existing, index-checked
uses of ``py::array``:
-- ``r.ndim()`` returns the number of dimensions
+- ``.ndim()`` returns the number of dimensions
-- ``r.data(1, 2, ...)`` and ``r.mutable_data(1, 2, ...)``` returns a pointer to
+- ``.data(1, 2, ...)`` and ``r.mutable_data(1, 2, ...)``` returns a pointer to
the ``const T`` or ``T`` data, respectively, at the given indices. The
latter is only available to proxies obtained via ``a.mutable_unchecked()``.
-- ``itemsize()`` returns the size of an item in bytes, i.e. ``sizeof(T)``.
+- ``.itemsize()`` returns the size of an item in bytes, i.e. ``sizeof(T)``.
-- ``ndim()`` returns the number of dimensions.
+- ``.ndim()`` returns the number of dimensions.
-- ``shape(n)`` returns the size of dimension ``n``
+- ``.shape(n)`` returns the size of dimension ``n``
-- ``size()`` returns the total number of elements (i.e. the product of the shapes).
+- ``.size()`` returns the total number of elements (i.e. the product of the shapes).
-- ``nbytes()`` returns the number of bytes used by the referenced elements
+- ``.nbytes()`` returns the number of bytes used by the referenced elements
(i.e. ``itemsize()`` times ``size()``).
.. seealso::
@@ -368,15 +395,13 @@ uses of ``py::array``:
Ellipsis
========
-Python 3 provides a convenient ``...`` ellipsis notation that is often used to
+Python provides a convenient ``...`` ellipsis notation that is often used to
slice multidimensional arrays. For instance, the following snippet extracts the
middle dimensions of a tensor with the first and last index set to zero.
-In Python 2, the syntactic sugar ``...`` is not available, but the singleton
-``Ellipsis`` (of type ``ellipsis``) can still be used directly.
.. code-block:: python
- a = # a NumPy array
+ a = ... # a NumPy array
b = a[0, ..., 0]
The function ``py::ellipsis()`` function can be used to perform the same
@@ -387,8 +412,6 @@ operation on the C++ side:
py::array a = /* A NumPy array */;
py::array b = a[py::make_tuple(0, py::ellipsis(), 0)];
-.. versionchanged:: 2.6
- ``py::ellipsis()`` is now also avaliable in Python 2.
Memory view
===========
@@ -410,7 +433,7 @@ following:
{ 2, 4 }, // shape (rows, cols)
{ sizeof(uint8_t) * 4, sizeof(uint8_t) } // strides in bytes
);
- })
+ });
This approach is meant for providing a ``memoryview`` for a C/C++ buffer not
managed by Python. The user is responsible for managing the lifetime of the
@@ -426,11 +449,7 @@ We can also use ``memoryview::from_memory`` for a simple 1D contiguous buffer:
buffer, // buffer pointer
sizeof(uint8_t) * 8 // buffer size
);
- })
-
-.. note::
-
- ``memoryview::from_memory`` is not available in Python 2.
+ });
.. versionchanged:: 2.6
``memoryview::from_memory`` added.
diff --git a/3rdparty/pybind11/docs/advanced/pycpp/object.rst b/3rdparty/pybind11/docs/advanced/pycpp/object.rst
index 6c7525ce..93e1a94d 100644
--- a/3rdparty/pybind11/docs/advanced/pycpp/object.rst
+++ b/3rdparty/pybind11/docs/advanced/pycpp/object.rst
@@ -20,6 +20,40 @@ Available types include :class:`handle`, :class:`object`, :class:`bool_`,
Be sure to review the :ref:`pytypes_gotchas` before using this heavily in
your C++ API.
+.. _instantiating_compound_types:
+
+Instantiating compound Python types from C++
+============================================
+
+Dictionaries can be initialized in the :class:`dict` constructor:
+
+.. code-block:: cpp
+
+ using namespace pybind11::literals; // to bring in the `_a` literal
+ py::dict d("spam"_a=py::none(), "eggs"_a=42);
+
+A tuple of python objects can be instantiated using :func:`py::make_tuple`:
+
+.. code-block:: cpp
+
+ py::tuple tup = py::make_tuple(42, py::none(), "spam");
+
+Each element is converted to a supported Python type.
+
+A `simple namespace`_ can be instantiated using
+
+.. code-block:: cpp
+
+ using namespace pybind11::literals; // to bring in the `_a` literal
+ py::object SimpleNamespace = py::module_::import("types").attr("SimpleNamespace");
+ py::object ns = SimpleNamespace("spam"_a=py::none(), "eggs"_a=42);
+
+Attributes on a namespace can be modified with the :func:`py::delattr`,
+:func:`py::getattr`, and :func:`py::setattr` functions. Simple namespaces can
+be useful as lightweight stand-ins for class instances.
+
+.. _simple namespace: https://docs.python.org/3/library/types.html#types.SimpleNamespace
+
.. _casting_back_and_forth:
Casting back and forth
@@ -30,7 +64,7 @@ types to Python, which can be done using :func:`py::cast`:
.. code-block:: cpp
- MyClass *cls = ..;
+ MyClass *cls = ...;
py::object obj = py::cast(cls);
The reverse direction uses the following syntax:
@@ -132,6 +166,7 @@ Keyword arguments are also supported. In Python, there is the usual call syntax:
def f(number, say, to):
... # function code
+
f(1234, say="hello", to=some_instance) # keyword call in Python
In C++, the same call can be made using:
diff --git a/3rdparty/pybind11/docs/advanced/pycpp/utilities.rst b/3rdparty/pybind11/docs/advanced/pycpp/utilities.rst
index c15051fb..af0f9cb2 100644
--- a/3rdparty/pybind11/docs/advanced/pycpp/utilities.rst
+++ b/3rdparty/pybind11/docs/advanced/pycpp/utilities.rst
@@ -28,7 +28,7 @@ Capturing standard output from ostream
Often, a library will use the streams ``std::cout`` and ``std::cerr`` to print,
but this does not play well with Python's standard ``sys.stdout`` and ``sys.stderr``
-redirection. Replacing a library's printing with `py::print <print>` may not
+redirection. Replacing a library's printing with ``py::print <print>`` may not
be feasible. This can be fixed using a guard around the library function that
redirects output to the corresponding Python streams:
@@ -47,15 +47,26 @@ redirects output to the corresponding Python streams:
call_noisy_func();
});
+.. warning::
+
+ The implementation in ``pybind11/iostream.h`` is NOT thread safe. Multiple
+ threads writing to a redirected ostream concurrently cause data races
+ and potentially buffer overflows. Therefore it is currently a requirement
+ that all (possibly) concurrent redirected ostream writes are protected by
+ a mutex. #HelpAppreciated: Work on iostream.h thread safety. For more
+ background see the discussions under
+ `PR #2982 <https://github.com/pybind/pybind11/pull/2982>`_ and
+ `PR #2995 <https://github.com/pybind/pybind11/pull/2995>`_.
+
This method respects flushes on the output streams and will flush if needed
when the scoped guard is destroyed. This allows the output to be redirected in
real time, such as to a Jupyter notebook. The two arguments, the C++ stream and
the Python output, are optional, and default to standard output if not given. An
-extra type, `py::scoped_estream_redirect <scoped_estream_redirect>`, is identical
+extra type, ``py::scoped_estream_redirect <scoped_estream_redirect>``, is identical
except for defaulting to ``std::cerr`` and ``sys.stderr``; this can be useful with
-`py::call_guard`, which allows multiple items, but uses the default constructor:
+``py::call_guard``, which allows multiple items, but uses the default constructor:
-.. code-block:: py
+.. code-block:: cpp
// Alternative: Call single function using call guard
m.def("noisy_func", &call_noisy_function,
@@ -63,7 +74,7 @@ except for defaulting to ``std::cerr`` and ``sys.stderr``; this can be useful wi
py::scoped_estream_redirect>());
The redirection can also be done in Python with the addition of a context
-manager, using the `py::add_ostream_redirect() <add_ostream_redirect>` function:
+manager, using the ``py::add_ostream_redirect() <add_ostream_redirect>`` function:
.. code-block:: cpp
@@ -92,7 +103,7 @@ arguments to disable one of the streams if needed.
Evaluating Python expressions from strings and files
====================================================
-pybind11 provides the `eval`, `exec` and `eval_file` functions to evaluate
+pybind11 provides the ``eval``, ``exec`` and ``eval_file`` functions to evaluate
Python expressions and statements. The following example illustrates how they
can be used.
diff --git a/3rdparty/pybind11/docs/advanced/smart_ptrs.rst b/3rdparty/pybind11/docs/advanced/smart_ptrs.rst
index da57748c..3c40ce12 100644
--- a/3rdparty/pybind11/docs/advanced/smart_ptrs.rst
+++ b/3rdparty/pybind11/docs/advanced/smart_ptrs.rst
@@ -77,6 +77,7 @@ segmentation fault).
.. code-block:: python
from example import Parent
+
print(Parent().get_child())
The problem is that ``Parent::get_child()`` returns a pointer to an instance of
@@ -156,7 +157,7 @@ specialized:
PYBIND11_DECLARE_HOLDER_TYPE(T, SmartPtr<T>);
// Only needed if the type's `.get()` goes by another name
- namespace pybind11 { namespace detail {
+ namespace PYBIND11_NAMESPACE { namespace detail {
template <typename T>
struct holder_helper<SmartPtr<T>> { // <-- specialization
static const T *get(const SmartPtr<T> &p) { return p.getPointer(); }
diff --git a/3rdparty/pybind11/docs/basics.rst b/3rdparty/pybind11/docs/basics.rst
index b9d386c3..e9b24c7f 100644
--- a/3rdparty/pybind11/docs/basics.rst
+++ b/3rdparty/pybind11/docs/basics.rst
@@ -32,8 +32,7 @@ The last line will both compile and run the tests.
Windows
-------
-On Windows, only **Visual Studio 2015** and newer are supported since pybind11 relies
-on various C++11 language features that break older versions of Visual Studio.
+On Windows, only **Visual Studio 2017** and newer are supported.
.. Note::
@@ -109,7 +108,7 @@ a file named :file:`example.cpp` with the following contents:
PYBIND11_MODULE(example, m) {
m.doc() = "pybind11 example plugin"; // optional module docstring
- m.def("add", &add, "A function which adds two numbers");
+ m.def("add", &add, "A function that adds two numbers");
}
.. [#f1] In practice, implementation and binding code will generally be located
@@ -136,7 +135,14 @@ On Linux, the above example can be compiled using the following command:
.. code-block:: bash
- $ c++ -O3 -Wall -shared -std=c++11 -fPIC `python3 -m pybind11 --includes` example.cpp -o example`python3-config --extension-suffix`
+ $ c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) example.cpp -o example$(python3-config --extension-suffix)
+
+.. note::
+
+ If you used :ref:`include_as_a_submodule` to get the pybind11 source, then
+ use ``$(python3-config --includes) -Iextern/pybind11/include`` instead of
+ ``$(python3 -m pybind11 --includes)`` in the above compilation, as
+ explained in :ref:`building_manually`.
For more details on the required compiler flags on Linux and macOS, see
:ref:`building_manually`. For complete cross-platform compilation instructions,
@@ -159,12 +165,12 @@ load and execute the example:
.. code-block:: pycon
$ python
- Python 2.7.10 (default, Aug 22 2015, 20:33:39)
- [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.1)] on darwin
+ Python 3.9.10 (main, Jan 15 2022, 11:48:04)
+ [Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import example
>>> example.add(1, 2)
- 3L
+ 3
>>>
.. _keyword_args:
diff --git a/3rdparty/pybind11/docs/benchmark.py b/3rdparty/pybind11/docs/benchmark.py
index 33d78fb4..2150b6ca 100644
--- a/3rdparty/pybind11/docs/benchmark.py
+++ b/3rdparty/pybind11/docs/benchmark.py
@@ -1,8 +1,6 @@
-# -*- coding: utf-8 -*-
-import random
-import os
-import time
import datetime as dt
+import os
+import random
nfns = 4 # Functions per class
nargs = 4 # Arguments per function
@@ -13,20 +11,20 @@ def generate_dummy_code_pybind11(nclasses=10):
bindings = ""
for cl in range(nclasses):
- decl += "class cl%03i;\n" % cl
+ decl += f"class cl{cl:03};\n"
decl += "\n"
for cl in range(nclasses):
- decl += "class cl%03i {\n" % cl
+ decl += f"class {cl:03} {{\n"
decl += "public:\n"
- bindings += ' py::class_<cl%03i>(m, "cl%03i")\n' % (cl, cl)
+ bindings += f' py::class_<cl{cl:03}>(m, "cl{cl:03}")\n'
for fn in range(nfns):
ret = random.randint(0, nclasses - 1)
params = [random.randint(0, nclasses - 1) for i in range(nargs)]
- decl += " cl%03i *fn_%03i(" % (ret, fn)
- decl += ", ".join("cl%03i *" % p for p in params)
+ decl += f" cl{ret:03} *fn_{fn:03}("
+ decl += ", ".join(f"cl{p:03} *" for p in params)
decl += ");\n"
- bindings += ' .def("fn_%03i", &cl%03i::fn_%03i)\n' % (fn, cl, fn)
+ bindings += f' .def("fn_{fn:03}", &cl{cl:03}::fn_{fn:03})\n'
decl += "};\n\n"
bindings += " ;\n"
@@ -44,23 +42,20 @@ def generate_dummy_code_boost(nclasses=10):
bindings = ""
for cl in range(nclasses):
- decl += "class cl%03i;\n" % cl
+ decl += f"class cl{cl:03};\n"
decl += "\n"
for cl in range(nclasses):
decl += "class cl%03i {\n" % cl
decl += "public:\n"
- bindings += ' py::class_<cl%03i>("cl%03i")\n' % (cl, cl)
+ bindings += f' py::class_<cl{cl:03}>("cl{cl:03}")\n'
for fn in range(nfns):
ret = random.randint(0, nclasses - 1)
params = [random.randint(0, nclasses - 1) for i in range(nargs)]
- decl += " cl%03i *fn_%03i(" % (ret, fn)
- decl += ", ".join("cl%03i *" % p for p in params)
+ decl += f" cl{ret:03} *fn_{fn:03}("
+ decl += ", ".join(f"cl{p:03} *" for p in params)
decl += ");\n"
- bindings += (
- ' .def("fn_%03i", &cl%03i::fn_%03i, py::return_value_policy<py::manage_new_object>())\n'
- % (fn, cl, fn)
- )
+ bindings += f' .def("fn_{fn:03}", &cl{cl:03}::fn_{fn:03}, py::return_value_policy<py::manage_new_object>())\n'
decl += "};\n\n"
bindings += " ;\n"
@@ -76,7 +71,7 @@ def generate_dummy_code_boost(nclasses=10):
for codegen in [generate_dummy_code_pybind11, generate_dummy_code_boost]:
print("{")
for i in range(0, 10):
- nclasses = 2 ** i
+ nclasses = 2**i
with open("test.cpp", "w") as f:
f.write(codegen(nclasses))
n1 = dt.datetime.now()
diff --git a/3rdparty/pybind11/docs/changelog.rst b/3rdparty/pybind11/docs/changelog.rst
index 561baa5f..9c8ff423 100644
--- a/3rdparty/pybind11/docs/changelog.rst
+++ b/3rdparty/pybind11/docs/changelog.rst
@@ -6,6 +6,931 @@ Changelog
Starting with version 1.8.0, pybind11 releases use a `semantic versioning
<http://semver.org>`_ policy.
+Changes will be added here periodically from the "Suggested changelog entry"
+block in pull request descriptions.
+
+
+
+IN DEVELOPMENT
+--------------
+
+Changes will be summarized here periodically.
+
+Version 2.10.0 (Jul 15, 2022)
+-----------------------------
+
+Removed support for Python 2.7, Python 3.5, and MSVC 2015. Support for MSVC
+2017 is limited due to availability of CI runners; we highly recommend MSVC
+2019 or 2022 be used. Initial support added for Python 3.11.
+
+New features:
+
+* ``py::anyset`` & ``py::frozenset`` were added, with copying (cast) to
+ ``std::set`` (similar to ``set``).
+ `#3901 <https://github.com/pybind/pybind11/pull/3901>`_
+
+* Support bytearray casting to string.
+ `#3707 <https://github.com/pybind/pybind11/pull/3707>`_
+
+* ``type_caster<std::monostate>`` was added. ``std::monostate`` is a tag type
+ that allows ``std::variant`` to act as an optional, or allows default
+ construction of a ``std::variant`` holding a non-default constructible type.
+ `#3818 <https://github.com/pybind/pybind11/pull/3818>`_
+
+* ``pybind11::capsule::set_name`` added to mutate the name of the capsule instance.
+ `#3866 <https://github.com/pybind/pybind11/pull/3866>`_
+
+* NumPy: dtype constructor from type number added, accessors corresponding to
+ Python API ``dtype.num``, ``dtype.byteorder``, ``dtype.flags`` and
+ ``dtype.alignment`` added.
+ `#3868 <https://github.com/pybind/pybind11/pull/3868>`_
+
+
+Changes:
+
+* Python 3.6 is now the minimum supported version.
+ `#3688 <https://github.com/pybind/pybind11/pull/3688>`_
+ `#3719 <https://github.com/pybind/pybind11/pull/3719>`_
+
+* The minimum version for MSVC is now 2017.
+ `#3722 <https://github.com/pybind/pybind11/pull/3722>`_
+
+* Fix issues with CPython 3.11 betas and add to supported test matrix.
+ `#3923 <https://github.com/pybind/pybind11/pull/3923>`_
+
+* ``error_already_set`` is now safer and more performant, especially for
+ exceptions with long tracebacks, by delaying computation.
+ `#1895 <https://github.com/pybind/pybind11/pull/1895>`_
+
+* Improve exception handling in python ``str`` bindings.
+ `#3826 <https://github.com/pybind/pybind11/pull/3826>`_
+
+* The bindings for capsules now have more consistent exception handling.
+ `#3825 <https://github.com/pybind/pybind11/pull/3825>`_
+
+* ``PYBIND11_OBJECT_CVT`` and ``PYBIND11_OBJECT_CVT_DEFAULT`` macro can now be
+ used to define classes in namespaces other than pybind11.
+ `#3797 <https://github.com/pybind/pybind11/pull/3797>`_
+
+* Error printing code now uses ``PYBIND11_DETAILED_ERROR_MESSAGES`` instead of
+ requiring ``NDEBUG``, allowing use with release builds if desired.
+ `#3913 <https://github.com/pybind/pybind11/pull/3913>`_
+
+* Implicit conversion of the literal ``0`` to ``pybind11::handle`` is now disabled.
+ `#4008 <https://github.com/pybind/pybind11/pull/4008>`_
+
+
+Bug fixes:
+
+* Fix exception handling when ``pybind11::weakref()`` fails.
+ `#3739 <https://github.com/pybind/pybind11/pull/3739>`_
+
+* ``module_::def_submodule`` was missing proper error handling. This is fixed now.
+ `#3973 <https://github.com/pybind/pybind11/pull/3973>`_
+
+* The behavior or ``error_already_set`` was made safer and the highly opaque
+ "Unknown internal error occurred" message was replaced with a more helpful
+ message.
+ `#3982 <https://github.com/pybind/pybind11/pull/3982>`_
+
+* ``error_already_set::what()`` now handles non-normalized exceptions correctly.
+ `#3971 <https://github.com/pybind/pybind11/pull/3971>`_
+
+* Support older C++ compilers where filesystem is not yet part of the standard
+ library and is instead included in ``std::experimental::filesystem``.
+ `#3840 <https://github.com/pybind/pybind11/pull/3840>`_
+
+* Fix ``-Wfree-nonheap-object`` warnings produced by GCC by avoiding returning
+ pointers to static objects with ``return_value_policy::take_ownership``.
+ `#3946 <https://github.com/pybind/pybind11/pull/3946>`_
+
+* Fix cast from pytype rvalue to another pytype.
+ `#3949 <https://github.com/pybind/pybind11/pull/3949>`_
+
+* Ensure proper behavior when garbage collecting classes with dynamic attributes in Python >=3.9.
+ `#4051 <https://github.com/pybind/pybind11/pull/4051>`_
+
+* A couple long-standing ``PYBIND11_NAMESPACE``
+ ``__attribute__((visibility("hidden")))`` inconsistencies are now fixed
+ (affects only unusual environments).
+ `#4043 <https://github.com/pybind/pybind11/pull/4043>`_
+
+* ``pybind11::detail::get_internals()`` is now resilient to in-flight Python
+ exceptions.
+ `#3981 <https://github.com/pybind/pybind11/pull/3981>`_
+
+* Arrays with a dimension of size 0 are now properly converted to dynamic Eigen
+ matrices (more common in NumPy 1.23).
+ `#4038 <https://github.com/pybind/pybind11/pull/4038>`_
+
+* Avoid catching unrelated errors when importing NumPy.
+ `#3974 <https://github.com/pybind/pybind11/pull/3974>`_
+
+Performance and style:
+
+* Added an accessor overload of ``(object &&key)`` to reference steal the
+ object when using python types as keys. This prevents unnecessary reference
+ count overhead for attr, dictionary, tuple, and sequence look ups. Added
+ additional regression tests. Fixed a performance bug the caused accessor
+ assignments to potentially perform unnecessary copies.
+ `#3970 <https://github.com/pybind/pybind11/pull/3970>`_
+
+* Perfect forward all args of ``make_iterator``.
+ `#3980 <https://github.com/pybind/pybind11/pull/3980>`_
+
+* Avoid potential bug in pycapsule destructor by adding an ``error_guard`` to
+ one of the dtors.
+ `#3958 <https://github.com/pybind/pybind11/pull/3958>`_
+
+* Optimize dictionary access in ``strip_padding`` for numpy.
+ `#3994 <https://github.com/pybind/pybind11/pull/3994>`_
+
+* ``stl_bind.h`` bindings now take slice args as a const-ref.
+ `#3852 <https://github.com/pybind/pybind11/pull/3852>`_
+
+* Made slice constructor more consistent, and improve performance of some
+ casters by allowing reference stealing.
+ `#3845 <https://github.com/pybind/pybind11/pull/3845>`_
+
+* Change numpy dtype from_args method to use const ref.
+ `#3878 <https://github.com/pybind/pybind11/pull/3878>`_
+
+* Follow rule of three to ensure ``PyErr_Restore`` is called only once.
+ `#3872 <https://github.com/pybind/pybind11/pull/3872>`_
+
+* Added missing perfect forwarding for ``make_iterator`` functions.
+ `#3860 <https://github.com/pybind/pybind11/pull/3860>`_
+
+* Optimize c++ to python function casting by using the rvalue caster.
+ `#3966 <https://github.com/pybind/pybind11/pull/3966>`_
+
+* Optimize Eigen sparse matrix casting by removing unnecessary temporary.
+ `#4064 <https://github.com/pybind/pybind11/pull/4064>`_
+
+* Avoid potential implicit copy/assignment constructors causing double free in
+ ``strdup_gaurd``.
+ `#3905 <https://github.com/pybind/pybind11/pull/3905>`_
+
+* Enable clang-tidy checks ``misc-definitions-in-headers``,
+ ``modernize-loop-convert``, and ``modernize-use-nullptr``.
+ `#3881 <https://github.com/pybind/pybind11/pull/3881>`_
+ `#3988 <https://github.com/pybind/pybind11/pull/3988>`_
+
+
+Build system improvements:
+
+* CMake: Fix file extension on Windows with cp36 and cp37 using FindPython.
+ `#3919 <https://github.com/pybind/pybind11/pull/3919>`_
+
+* CMake: Support multiple Python targets (such as on vcpkg).
+ `#3948 <https://github.com/pybind/pybind11/pull/3948>`_
+
+* CMake: Fix issue with NVCC on Windows.
+ `#3947 <https://github.com/pybind/pybind11/pull/3947>`_
+
+* CMake: Drop the bitness check on cross compiles (like targeting WebAssembly
+ via Emscripten).
+ `#3959 <https://github.com/pybind/pybind11/pull/3959>`_
+
+* Add MSVC builds in debug mode to CI.
+ `#3784 <https://github.com/pybind/pybind11/pull/3784>`_
+
+* MSVC 2022 C++20 coverage was added to GitHub Actions, including Eigen.
+ `#3732 <https://github.com/pybind/pybind11/pull/3732>`_,
+ `#3741 <https://github.com/pybind/pybind11/pull/3741>`_
+
+
+Backend and tidying up:
+
+* New theme for the documentation.
+ `#3109 <https://github.com/pybind/pybind11/pull/3109>`_
+
+* Remove idioms in code comments. Use more inclusive language.
+ `#3809 <https://github.com/pybind/pybind11/pull/3809>`_
+
+* ``#include <iostream>`` was removed from the ``pybind11/stl.h`` header. Your
+ project may break if it has a transitive dependency on this include. The fix
+ is to "Include What You Use".
+ `#3928 <https://github.com/pybind/pybind11/pull/3928>`_
+
+* Avoid ``setup.py <command>`` usage in internal tests.
+ `#3734 <https://github.com/pybind/pybind11/pull/3734>`_
+
+
+Version 2.9.2 (Mar 29, 2022)
+----------------------------
+
+Changes:
+
+* Enum now has an ``__index__`` method on Python <3.8 too.
+ `#3700 <https://github.com/pybind/pybind11/pull/3700>`_
+
+* Local internals are now cleared after finalizing the interpreter.
+ `#3744 <https://github.com/pybind/pybind11/pull/3744>`_
+
+Bug fixes:
+
+* Better support for Python 3.11 alphas.
+ `#3694 <https://github.com/pybind/pybind11/pull/3694>`_
+
+* ``PYBIND11_TYPE_CASTER`` now uses fully qualified symbols, so it can be used
+ outside of ``pybind11::detail``.
+ `#3758 <https://github.com/pybind/pybind11/pull/3758>`_
+
+* Some fixes for PyPy 3.9.
+ `#3768 <https://github.com/pybind/pybind11/pull/3768>`_
+
+* Fixed a potential memleak in PyPy in ``get_type_override``.
+ `#3774 <https://github.com/pybind/pybind11/pull/3774>`_
+
+* Fix usage of ``VISIBILITY_INLINES_HIDDEN``.
+ `#3721 <https://github.com/pybind/pybind11/pull/3721>`_
+
+
+Build system improvements:
+
+* Uses ``sysconfig`` module to determine installation locations on Python >=
+ 3.10, instead of ``distutils`` which has been deprecated.
+ `#3764 <https://github.com/pybind/pybind11/pull/3764>`_
+
+* Support Catch 2.13.5+ (supporting GLIBC 2.34+).
+ `#3679 <https://github.com/pybind/pybind11/pull/3679>`_
+
+* Fix test failures with numpy 1.22 by ignoring whitespace when comparing
+ ``str()`` of dtypes.
+ `#3682 <https://github.com/pybind/pybind11/pull/3682>`_
+
+
+Backend and tidying up:
+
+* clang-tidy: added ``readability-qualified-auto``,
+ ``readability-braces-around-statements``,
+ ``cppcoreguidelines-prefer-member-initializer``,
+ ``clang-analyzer-optin.performance.Padding``,
+ ``cppcoreguidelines-pro-type-static-cast-downcast``, and
+ ``readability-inconsistent-declaration-parameter-name``.
+ `#3702 <https://github.com/pybind/pybind11/pull/3702>`_,
+ `#3699 <https://github.com/pybind/pybind11/pull/3699>`_,
+ `#3716 <https://github.com/pybind/pybind11/pull/3716>`_,
+ `#3709 <https://github.com/pybind/pybind11/pull/3709>`_
+
+* clang-format was added to the pre-commit actions, and the entire code base
+ automatically reformatted (after several iterations preparing for this leap).
+ `#3713 <https://github.com/pybind/pybind11/pull/3713>`_
+
+
+Version 2.9.1 (Feb 2, 2022)
+---------------------------
+
+Changes:
+
+* If possible, attach Python exception with ``py::raise_from`` to ``TypeError``
+ when casting from C++ to Python. This will give additional info if Python
+ exceptions occur in the caster. Adds a test case of trying to convert a set
+ from C++ to Python when the hash function is not defined in Python.
+ `#3605 <https://github.com/pybind/pybind11/pull/3605>`_
+
+* Add a mapping of C++11 nested exceptions to their Python exception
+ equivalent using ``py::raise_from``. This attaches the nested exceptions in
+ Python using the ``__cause__`` field.
+ `#3608 <https://github.com/pybind/pybind11/pull/3608>`_
+
+* Propagate Python exception traceback using ``raise_from`` if a pybind11
+ function runs out of overloads.
+ `#3671 <https://github.com/pybind/pybind11/pull/3671>`_
+
+* ``py::multiple_inheritance`` is now only needed when C++ bases are hidden
+ from pybind11.
+ `#3650 <https://github.com/pybind/pybind11/pull/3650>`_ and
+ `#3659 <https://github.com/pybind/pybind11/pull/3659>`_
+
+
+Bug fixes:
+
+* Remove a boolean cast in ``numpy.h`` that causes MSVC C4800 warnings when
+ compiling against Python 3.10 or newer.
+ `#3669 <https://github.com/pybind/pybind11/pull/3669>`_
+
+* Render ``py::bool_`` and ``py::float_`` as ``bool`` and ``float``
+ respectively.
+ `#3622 <https://github.com/pybind/pybind11/pull/3622>`_
+
+Build system improvements:
+
+* Fix CMake extension suffix computation on Python 3.10+.
+ `#3663 <https://github.com/pybind/pybind11/pull/3663>`_
+
+* Allow ``CMAKE_ARGS`` to override CMake args in pybind11's own ``setup.py``.
+ `#3577 <https://github.com/pybind/pybind11/pull/3577>`_
+
+* Remove a few deprecated c-headers.
+ `#3610 <https://github.com/pybind/pybind11/pull/3610>`_
+
+* More uniform handling of test targets.
+ `#3590 <https://github.com/pybind/pybind11/pull/3590>`_
+
+* Add clang-tidy readability check to catch potentially swapped function args.
+ `#3611 <https://github.com/pybind/pybind11/pull/3611>`_
+
+
+Version 2.9.0 (Dec 28, 2021)
+----------------------------
+
+This is the last version to support Python 2.7 and 3.5.
+
+New Features:
+
+* Allow ``py::args`` to be followed by other arguments; the remaining arguments
+ are implicitly keyword-only, as if a ``py::kw_only{}`` annotation had been
+ used.
+ `#3402 <https://github.com/pybind/pybind11/pull/3402>`_
+
+Changes:
+
+* Make str/bytes/memoryview more interoperable with ``std::string_view``.
+ `#3521 <https://github.com/pybind/pybind11/pull/3521>`_
+
+* Replace ``_`` with ``const_name`` in internals, avoid defining ``pybind::_``
+ if ``_`` defined as macro (common gettext usage)
+ `#3423 <https://github.com/pybind/pybind11/pull/3423>`_
+
+
+Bug fixes:
+
+* Fix a rare warning about extra copy in an Eigen constructor.
+ `#3486 <https://github.com/pybind/pybind11/pull/3486>`_
+
+* Fix caching of the C++ overrides.
+ `#3465 <https://github.com/pybind/pybind11/pull/3465>`_
+
+* Add missing ``std::forward`` calls to some ``cpp_function`` overloads.
+ `#3443 <https://github.com/pybind/pybind11/pull/3443>`_
+
+* Support PyPy 7.3.7 and the PyPy3.8 beta. Test python-3.11 on PRs with the
+ ``python dev`` label.
+ `#3419 <https://github.com/pybind/pybind11/pull/3419>`_
+
+* Replace usage of deprecated ``Eigen::MappedSparseMatrix`` with
+ ``Eigen::Map<Eigen::SparseMatrix<...>>`` for Eigen 3.3+.
+ `#3499 <https://github.com/pybind/pybind11/pull/3499>`_
+
+* Tweaks to support Microsoft Visual Studio 2022.
+ `#3497 <https://github.com/pybind/pybind11/pull/3497>`_
+
+Build system improvements:
+
+* Nicer CMake printout and IDE organisation for pybind11's own tests.
+ `#3479 <https://github.com/pybind/pybind11/pull/3479>`_
+
+* CMake: report version type as part of the version string to avoid a spurious
+ space in the package status message.
+ `#3472 <https://github.com/pybind/pybind11/pull/3472>`_
+
+* Flags starting with ``-g`` in ``$CFLAGS`` and ``$CPPFLAGS`` are no longer
+ overridden by ``.Pybind11Extension``.
+ `#3436 <https://github.com/pybind/pybind11/pull/3436>`_
+
+* Ensure ThreadPool is closed in ``setup_helpers``.
+ `#3548 <https://github.com/pybind/pybind11/pull/3548>`_
+
+* Avoid LTS on ``mips64`` and ``ppc64le`` (reported broken).
+ `#3557 <https://github.com/pybind/pybind11/pull/3557>`_
+
+
+v2.8.1 (Oct 27, 2021)
+---------------------
+
+Changes and additions:
+
+* The simple namespace creation shortcut added in 2.8.0 was deprecated due to
+ usage of CPython internal API, and will be removed soon. Use
+ ``py::module_::import("types").attr("SimpleNamespace")``.
+ `#3374 <https://github.com/pybinyyd/pybind11/pull/3374>`_
+
+* Add C++ Exception type to throw and catch ``AttributeError``. Useful for
+ defining custom ``__setattr__`` and ``__getattr__`` methods.
+ `#3387 <https://github.com/pybind/pybind11/pull/3387>`_
+
+Fixes:
+
+* Fixed the potential for dangling references when using properties with
+ ``std::optional`` types.
+ `#3376 <https://github.com/pybind/pybind11/pull/3376>`_
+
+* Modernize usage of ``PyCodeObject`` on Python 3.9+ (moving toward support for
+ Python 3.11a1)
+ `#3368 <https://github.com/pybind/pybind11/pull/3368>`_
+
+* A long-standing bug in ``eigen.h`` was fixed (originally PR #3343). The bug
+ was unmasked by newly added ``static_assert``'s in the Eigen 3.4.0 release.
+ `#3352 <https://github.com/pybind/pybind11/pull/3352>`_
+
+* Support multiple raw inclusion of CMake helper files (Conan.io does this for
+ multi-config generators).
+ `#3420 <https://github.com/pybind/pybind11/pull/3420>`_
+
+* Fix harmless warning on upcoming CMake 3.22.
+ `#3368 <https://github.com/pybind/pybind11/pull/3368>`_
+
+* Fix 2.8.0 regression with MSVC 2017 + C++17 mode + Python 3.
+ `#3407 <https://github.com/pybind/pybind11/pull/3407>`_
+
+* Fix 2.8.0 regression that caused undefined behavior (typically
+ segfaults) in ``make_key_iterator``/``make_value_iterator`` if dereferencing
+ the iterator returned a temporary value instead of a reference.
+ `#3348 <https://github.com/pybind/pybind11/pull/3348>`_
+
+
+v2.8.0 (Oct 4, 2021)
+--------------------
+
+New features:
+
+* Added ``py::raise_from`` to enable chaining exceptions.
+ `#3215 <https://github.com/pybind/pybind11/pull/3215>`_
+
+* Allow exception translators to be optionally registered local to a module
+ instead of applying globally across all pybind11 modules. Use
+ ``register_local_exception_translator(ExceptionTranslator&& translator)``
+ instead of ``register_exception_translator(ExceptionTranslator&&
+ translator)`` to keep your exception remapping code local to the module.
+ `#2650 <https://github.com/pybinyyd/pybind11/pull/2650>`_
+
+* Add ``make_simple_namespace`` function for instantiating Python
+ ``SimpleNamespace`` objects. **Deprecated in 2.8.1.**
+ `#2840 <https://github.com/pybind/pybind11/pull/2840>`_
+
+* ``pybind11::scoped_interpreter`` and ``initialize_interpreter`` have new
+ arguments to allow ``sys.argv`` initialization.
+ `#2341 <https://github.com/pybind/pybind11/pull/2341>`_
+
+* Allow Python builtins to be used as callbacks in CPython.
+ `#1413 <https://github.com/pybind/pybind11/pull/1413>`_
+
+* Added ``view`` to view arrays with a different datatype.
+ `#987 <https://github.com/pybind/pybind11/pull/987>`_
+
+* Implemented ``reshape`` on arrays.
+ `#984 <https://github.com/pybind/pybind11/pull/984>`_
+
+* Enable defining custom ``__new__`` methods on classes by fixing bug
+ preventing overriding methods if they have non-pybind11 siblings.
+ `#3265 <https://github.com/pybind/pybind11/pull/3265>`_
+
+* Add ``make_value_iterator()``, and fix ``make_key_iterator()`` to return
+ references instead of copies.
+ `#3293 <https://github.com/pybind/pybind11/pull/3293>`_
+
+* Improve the classes generated by ``bind_map``: `#3310 <https://github.com/pybind/pybind11/pull/3310>`_
+
+ * Change ``.items`` from an iterator to a dictionary view.
+ * Add ``.keys`` and ``.values`` (both dictionary views).
+ * Allow ``__contains__`` to take any object.
+
+* ``pybind11::custom_type_setup`` was added, for customizing the
+ ``PyHeapTypeObject`` corresponding to a class, which may be useful for
+ enabling garbage collection support, among other things.
+ `#3287 <https://github.com/pybind/pybind11/pull/3287>`_
+
+
+Changes:
+
+* Set ``__file__`` constant when running ``eval_file`` in an embedded interpreter.
+ `#3233 <https://github.com/pybind/pybind11/pull/3233>`_
+
+* Python objects and (C++17) ``std::optional`` now accepted in ``py::slice``
+ constructor.
+ `#1101 <https://github.com/pybind/pybind11/pull/1101>`_
+
+* The pybind11 proxy types ``str``, ``bytes``, ``bytearray``, ``tuple``,
+ ``list`` now consistently support passing ``ssize_t`` values for sizes and
+ indexes. Previously, only ``size_t`` was accepted in several interfaces.
+ `#3219 <https://github.com/pybind/pybind11/pull/3219>`_
+
+* Avoid evaluating ``PYBIND11_TLS_REPLACE_VALUE`` arguments more than once.
+ `#3290 <https://github.com/pybind/pybind11/pull/3290>`_
+
+Fixes:
+
+* Bug fix: enum value's ``__int__`` returning non-int when underlying type is
+ bool or of char type.
+ `#1334 <https://github.com/pybind/pybind11/pull/1334>`_
+
+* Fixes bug in setting error state in Capsule's pointer methods.
+ `#3261 <https://github.com/pybind/pybind11/pull/3261>`_
+
+* A long-standing memory leak in ``py::cpp_function::initialize`` was fixed.
+ `#3229 <https://github.com/pybind/pybind11/pull/3229>`_
+
+* Fixes thread safety for some ``pybind11::type_caster`` which require lifetime
+ extension, such as for ``std::string_view``.
+ `#3237 <https://github.com/pybind/pybind11/pull/3237>`_
+
+* Restore compatibility with gcc 4.8.4 as distributed by ubuntu-trusty, linuxmint-17.
+ `#3270 <https://github.com/pybind/pybind11/pull/3270>`_
+
+
+Build system improvements:
+
+* Fix regression in CMake Python package config: improper use of absolute path.
+ `#3144 <https://github.com/pybind/pybind11/pull/3144>`_
+
+* Cached Python version information could become stale when CMake was re-run
+ with a different Python version. The build system now detects this and
+ updates this information.
+ `#3299 <https://github.com/pybind/pybind11/pull/3299>`_
+
+* Specified UTF8-encoding in setup.py calls of open().
+ `#3137 <https://github.com/pybind/pybind11/pull/3137>`_
+
+* Fix a harmless warning from CMake 3.21 with the classic Python discovery.
+ `#3220 <https://github.com/pybind/pybind11/pull/3220>`_
+
+* Eigen repo and version can now be specified as cmake options.
+ `#3324 <https://github.com/pybind/pybind11/pull/3324>`_
+
+
+Backend and tidying up:
+
+* Reduced thread-local storage required for keeping alive temporary data for
+ type conversion to one key per ABI version, rather than one key per extension
+ module. This makes the total thread-local storage required by pybind11 2
+ keys per ABI version.
+ `#3275 <https://github.com/pybind/pybind11/pull/3275>`_
+
+* Optimize NumPy array construction with additional moves.
+ `#3183 <https://github.com/pybind/pybind11/pull/3183>`_
+
+* Conversion to ``std::string`` and ``std::string_view`` now avoids making an
+ extra copy of the data on Python >= 3.3.
+ `#3257 <https://github.com/pybind/pybind11/pull/3257>`_
+
+* Remove const modifier from certain C++ methods on Python collections
+ (``list``, ``set``, ``dict``) such as (``clear()``, ``append()``,
+ ``insert()``, etc...) and annotated them with ``py-non-const``.
+
+* Enable readability ``clang-tidy-const-return`` and remove useless consts.
+ `#3254 <https://github.com/pybind/pybind11/pull/3254>`_
+ `#3194 <https://github.com/pybind/pybind11/pull/3194>`_
+
+* The clang-tidy ``google-explicit-constructor`` option was enabled.
+ `#3250 <https://github.com/pybind/pybind11/pull/3250>`_
+
+* Mark a pytype move constructor as noexcept (perf).
+ `#3236 <https://github.com/pybind/pybind11/pull/3236>`_
+
+* Enable clang-tidy check to guard against inheritance slicing.
+ `#3210 <https://github.com/pybind/pybind11/pull/3210>`_
+
+* Legacy warning suppression pragma were removed from eigen.h. On Unix
+ platforms, please use -isystem for Eigen include directories, to suppress
+ compiler warnings originating from Eigen headers. Note that CMake does this
+ by default. No adjustments are needed for Windows.
+ `#3198 <https://github.com/pybind/pybind11/pull/3198>`_
+
+* Format pybind11 with isort consistent ordering of imports
+ `#3195 <https://github.com/pybind/pybind11/pull/3195>`_
+
+* The warnings-suppression "pragma clamp" at the top/bottom of pybind11 was
+ removed, clearing the path to refactoring and IWYU cleanup.
+ `#3186 <https://github.com/pybind/pybind11/pull/3186>`_
+
+* Enable most bugprone checks in clang-tidy and fix the found potential bugs
+ and poor coding styles.
+ `#3166 <https://github.com/pybind/pybind11/pull/3166>`_
+
+* Add ``clang-tidy-readability`` rules to make boolean casts explicit improving
+ code readability. Also enabled other misc and readability clang-tidy checks.
+ `#3148 <https://github.com/pybind/pybind11/pull/3148>`_
+
+* Move object in ``.pop()`` for list.
+ `#3116 <https://github.com/pybind/pybind11/pull/3116>`_
+
+
+
+
+v2.7.1 (Aug 3, 2021)
+---------------------
+
+Minor missing functionality added:
+
+* Allow Python builtins to be used as callbacks in CPython.
+ `#1413 <https://github.com/pybind/pybind11/pull/1413>`_
+
+Bug fixes:
+
+* Fix regression in CMake Python package config: improper use of absolute path.
+ `#3144 <https://github.com/pybind/pybind11/pull/3144>`_
+
+* Fix Mingw64 and add to the CI testing matrix.
+ `#3132 <https://github.com/pybind/pybind11/pull/3132>`_
+
+* Specified UTF8-encoding in setup.py calls of open().
+ `#3137 <https://github.com/pybind/pybind11/pull/3137>`_
+
+* Add clang-tidy-readability rules to make boolean casts explicit improving
+ code readability. Also enabled other misc and readability clang-tidy checks.
+ `#3148 <https://github.com/pybind/pybind11/pull/3148>`_
+
+* Move object in ``.pop()`` for list.
+ `#3116 <https://github.com/pybind/pybind11/pull/3116>`_
+
+Backend and tidying up:
+
+* Removed and fixed warning suppressions.
+ `#3127 <https://github.com/pybind/pybind11/pull/3127>`_
+ `#3129 <https://github.com/pybind/pybind11/pull/3129>`_
+ `#3135 <https://github.com/pybind/pybind11/pull/3135>`_
+ `#3141 <https://github.com/pybind/pybind11/pull/3141>`_
+ `#3142 <https://github.com/pybind/pybind11/pull/3142>`_
+ `#3150 <https://github.com/pybind/pybind11/pull/3150>`_
+ `#3152 <https://github.com/pybind/pybind11/pull/3152>`_
+ `#3160 <https://github.com/pybind/pybind11/pull/3160>`_
+ `#3161 <https://github.com/pybind/pybind11/pull/3161>`_
+
+
+v2.7.0 (Jul 16, 2021)
+---------------------
+
+New features:
+
+* Enable ``py::implicitly_convertible<py::none, ...>`` for
+ ``py::class_``-wrapped types.
+ `#3059 <https://github.com/pybind/pybind11/pull/3059>`_
+
+* Allow function pointer extraction from overloaded functions.
+ `#2944 <https://github.com/pybind/pybind11/pull/2944>`_
+
+* NumPy: added ``.char_()`` to type which gives the NumPy public ``char``
+ result, which also distinguishes types by bit length (unlike ``.kind()``).
+ `#2864 <https://github.com/pybind/pybind11/pull/2864>`_
+
+* Add ``pybind11::bytearray`` to manipulate ``bytearray`` similar to ``bytes``.
+ `#2799 <https://github.com/pybind/pybind11/pull/2799>`_
+
+* ``pybind11/stl/filesystem.h`` registers a type caster that, on C++17/Python
+ 3.6+, converts ``std::filesystem::path`` to ``pathlib.Path`` and any
+ ``os.PathLike`` to ``std::filesystem::path``.
+ `#2730 <https://github.com/pybind/pybind11/pull/2730>`_
+
+* A ``PYBIND11_VERSION_HEX`` define was added, similar to ``PY_VERSION_HEX``.
+ `#3120 <https://github.com/pybind/pybind11/pull/3120>`_
+
+
+
+Changes:
+
+* ``py::str`` changed to exclusively hold ``PyUnicodeObject``. Previously
+ ``py::str`` could also hold ``bytes``, which is probably surprising, was
+ never documented, and can mask bugs (e.g. accidental use of ``py::str``
+ instead of ``py::bytes``).
+ `#2409 <https://github.com/pybind/pybind11/pull/2409>`_
+
+* Add a safety guard to ensure that the Python GIL is held when C++ calls back
+ into Python via ``object_api<>::operator()`` (e.g. ``py::function``
+ ``__call__``). (This feature is available for Python 3.6+ only.)
+ `#2919 <https://github.com/pybind/pybind11/pull/2919>`_
+
+* Catch a missing ``self`` argument in calls to ``__init__()``.
+ `#2914 <https://github.com/pybind/pybind11/pull/2914>`_
+
+* Use ``std::string_view`` if available to avoid a copy when passing an object
+ to a ``std::ostream``.
+ `#3042 <https://github.com/pybind/pybind11/pull/3042>`_
+
+* An important warning about thread safety was added to the ``iostream.h``
+ documentation; attempts to make ``py::scoped_ostream_redirect`` thread safe
+ have been removed, as it was only partially effective.
+ `#2995 <https://github.com/pybind/pybind11/pull/2995>`_
+
+
+Fixes:
+
+* Performance: avoid unnecessary strlen calls.
+ `#3058 <https://github.com/pybind/pybind11/pull/3058>`_
+
+* Fix auto-generated documentation string when using ``const T`` in
+ ``pyarray_t``.
+ `#3020 <https://github.com/pybind/pybind11/pull/3020>`_
+
+* Unify error messages thrown by ``simple_collector``/``unpacking_collector``.
+ `#3013 <https://github.com/pybind/pybind11/pull/3013>`_
+
+* ``pybind11::builtin_exception`` is now explicitly exported, which means the
+ types included/defined in different modules are identical, and exceptions
+ raised in different modules can be caught correctly. The documentation was
+ updated to explain that custom exceptions that are used across module
+ boundaries need to be explicitly exported as well.
+ `#2999 <https://github.com/pybind/pybind11/pull/2999>`_
+
+* Fixed exception when printing UTF-8 to a ``scoped_ostream_redirect``.
+ `#2982 <https://github.com/pybind/pybind11/pull/2982>`_
+
+* Pickle support enhancement: ``setstate`` implementation will attempt to
+ ``setattr`` ``__dict__`` only if the unpickled ``dict`` object is not empty,
+ to not force use of ``py::dynamic_attr()`` unnecessarily.
+ `#2972 <https://github.com/pybind/pybind11/pull/2972>`_
+
+* Allow negative timedelta values to roundtrip.
+ `#2870 <https://github.com/pybind/pybind11/pull/2870>`_
+
+* Fix unchecked errors could potentially swallow signals/other exceptions.
+ `#2863 <https://github.com/pybind/pybind11/pull/2863>`_
+
+* Add null pointer check with ``std::localtime``.
+ `#2846 <https://github.com/pybind/pybind11/pull/2846>`_
+
+* Fix the ``weakref`` constructor from ``py::object`` to create a new
+ ``weakref`` on conversion.
+ `#2832 <https://github.com/pybind/pybind11/pull/2832>`_
+
+* Avoid relying on exceptions in C++17 when getting a ``shared_ptr`` holder
+ from a ``shared_from_this`` class.
+ `#2819 <https://github.com/pybind/pybind11/pull/2819>`_
+
+* Allow the codec's exception to be raised instead of :code:`RuntimeError` when
+ casting from :code:`py::str` to :code:`std::string`.
+ `#2903 <https://github.com/pybind/pybind11/pull/2903>`_
+
+
+Build system improvements:
+
+* In ``setup_helpers.py``, test for platforms that have some multiprocessing
+ features but lack semaphores, which ``ParallelCompile`` requires.
+ `#3043 <https://github.com/pybind/pybind11/pull/3043>`_
+
+* Fix ``pybind11_INCLUDE_DIR`` in case ``CMAKE_INSTALL_INCLUDEDIR`` is
+ absolute.
+ `#3005 <https://github.com/pybind/pybind11/pull/3005>`_
+
+* Fix bug not respecting ``WITH_SOABI`` or ``WITHOUT_SOABI`` to CMake.
+ `#2938 <https://github.com/pybind/pybind11/pull/2938>`_
+
+* Fix the default ``Pybind11Extension`` compilation flags with a Mingw64 python.
+ `#2921 <https://github.com/pybind/pybind11/pull/2921>`_
+
+* Clang on Windows: do not pass ``/MP`` (ignored flag).
+ `#2824 <https://github.com/pybind/pybind11/pull/2824>`_
+
+* ``pybind11.setup_helpers.intree_extensions`` can be used to generate
+ ``Pybind11Extension`` instances from cpp files placed in the Python package
+ source tree.
+ `#2831 <https://github.com/pybind/pybind11/pull/2831>`_
+
+Backend and tidying up:
+
+* Enable clang-tidy performance, readability, and modernization checks
+ throughout the codebase to enforce best coding practices.
+ `#3046 <https://github.com/pybind/pybind11/pull/3046>`_,
+ `#3049 <https://github.com/pybind/pybind11/pull/3049>`_,
+ `#3051 <https://github.com/pybind/pybind11/pull/3051>`_,
+ `#3052 <https://github.com/pybind/pybind11/pull/3052>`_,
+ `#3080 <https://github.com/pybind/pybind11/pull/3080>`_, and
+ `#3094 <https://github.com/pybind/pybind11/pull/3094>`_
+
+
+* Checks for common misspellings were added to the pre-commit hooks.
+ `#3076 <https://github.com/pybind/pybind11/pull/3076>`_
+
+* Changed ``Werror`` to stricter ``Werror-all`` for Intel compiler and fixed
+ minor issues.
+ `#2948 <https://github.com/pybind/pybind11/pull/2948>`_
+
+* Fixed compilation with GCC < 5 when the user defines ``_GLIBCXX_USE_CXX11_ABI``.
+ `#2956 <https://github.com/pybind/pybind11/pull/2956>`_
+
+* Added nox support for easier local testing and linting of contributions.
+ `#3101 <https://github.com/pybind/pybind11/pull/3101>`_ and
+ `#3121 <https://github.com/pybind/pybind11/pull/3121>`_
+
+* Avoid RTD style issue with docutils 0.17+.
+ `#3119 <https://github.com/pybind/pybind11/pull/3119>`_
+
+* Support pipx run, such as ``pipx run pybind11 --include`` for a quick compile.
+ `#3117 <https://github.com/pybind/pybind11/pull/3117>`_
+
+
+
+v2.6.2 (Jan 26, 2021)
+---------------------
+
+Minor missing functionality added:
+
+* enum: add missing Enum.value property.
+ `#2739 <https://github.com/pybind/pybind11/pull/2739>`_
+
+* Allow thread termination to be avoided during shutdown for CPython 3.7+ via
+ ``.disarm`` for ``gil_scoped_acquire``/``gil_scoped_release``.
+ `#2657 <https://github.com/pybind/pybind11/pull/2657>`_
+
+Fixed or improved behavior in a few special cases:
+
+* Fix bug where the constructor of ``object`` subclasses would not throw on
+ being passed a Python object of the wrong type.
+ `#2701 <https://github.com/pybind/pybind11/pull/2701>`_
+
+* The ``type_caster`` for integers does not convert Python objects with
+ ``__int__`` anymore with ``noconvert`` or during the first round of trying
+ overloads.
+ `#2698 <https://github.com/pybind/pybind11/pull/2698>`_
+
+* When casting to a C++ integer, ``__index__`` is always called and not
+ considered as conversion, consistent with Python 3.8+.
+ `#2801 <https://github.com/pybind/pybind11/pull/2801>`_
+
+Build improvements:
+
+* Setup helpers: ``extra_compile_args`` and ``extra_link_args`` automatically set by
+ Pybind11Extension are now prepended, which allows them to be overridden
+ by user-set ``extra_compile_args`` and ``extra_link_args``.
+ `#2808 <https://github.com/pybind/pybind11/pull/2808>`_
+
+* Setup helpers: Don't trigger unused parameter warning.
+ `#2735 <https://github.com/pybind/pybind11/pull/2735>`_
+
+* CMake: Support running with ``--warn-uninitialized`` active.
+ `#2806 <https://github.com/pybind/pybind11/pull/2806>`_
+
+* CMake: Avoid error if included from two submodule directories.
+ `#2804 <https://github.com/pybind/pybind11/pull/2804>`_
+
+* CMake: Fix ``STATIC`` / ``SHARED`` being ignored in FindPython mode.
+ `#2796 <https://github.com/pybind/pybind11/pull/2796>`_
+
+* CMake: Respect the setting for ``CMAKE_CXX_VISIBILITY_PRESET`` if defined.
+ `#2793 <https://github.com/pybind/pybind11/pull/2793>`_
+
+* CMake: Fix issue with FindPython2/FindPython3 not working with ``pybind11::embed``.
+ `#2662 <https://github.com/pybind/pybind11/pull/2662>`_
+
+* CMake: mixing local and installed pybind11's would prioritize the installed
+ one over the local one (regression in 2.6.0).
+ `#2716 <https://github.com/pybind/pybind11/pull/2716>`_
+
+
+Bug fixes:
+
+* Fixed segfault in multithreaded environments when using
+ ``scoped_ostream_redirect``.
+ `#2675 <https://github.com/pybind/pybind11/pull/2675>`_
+
+* Leave docstring unset when all docstring-related options are disabled, rather
+ than set an empty string.
+ `#2745 <https://github.com/pybind/pybind11/pull/2745>`_
+
+* The module key in builtins that pybind11 uses to store its internals changed
+ from std::string to a python str type (more natural on Python 2, no change on
+ Python 3).
+ `#2814 <https://github.com/pybind/pybind11/pull/2814>`_
+
+* Fixed assertion error related to unhandled (later overwritten) exception in
+ CPython 3.8 and 3.9 debug builds.
+ `#2685 <https://github.com/pybind/pybind11/pull/2685>`_
+
+* Fix ``py::gil_scoped_acquire`` assert with CPython 3.9 debug build.
+ `#2683 <https://github.com/pybind/pybind11/pull/2683>`_
+
+* Fix issue with a test failing on pytest 6.2.
+ `#2741 <https://github.com/pybind/pybind11/pull/2741>`_
+
+Warning fixes:
+
+* Fix warning modifying constructor parameter 'flag' that shadows a field of
+ 'set_flag' ``[-Wshadow-field-in-constructor-modified]``.
+ `#2780 <https://github.com/pybind/pybind11/pull/2780>`_
+
+* Suppressed some deprecation warnings about old-style
+ ``__init__``/``__setstate__`` in the tests.
+ `#2759 <https://github.com/pybind/pybind11/pull/2759>`_
+
+Valgrind work:
+
+* Fix invalid access when calling a pybind11 ``__init__`` on a non-pybind11
+ class instance.
+ `#2755 <https://github.com/pybind/pybind11/pull/2755>`_
+
+* Fixed various minor memory leaks in pybind11's test suite.
+ `#2758 <https://github.com/pybind/pybind11/pull/2758>`_
+
+* Resolved memory leak in cpp_function initialization when exceptions occurred.
+ `#2756 <https://github.com/pybind/pybind11/pull/2756>`_
+
+* Added a Valgrind build, checking for leaks and memory-related UB, to CI.
+ `#2746 <https://github.com/pybind/pybind11/pull/2746>`_
+
+Compiler support:
+
+* Intel compiler was not activating C++14 support due to a broken define.
+ `#2679 <https://github.com/pybind/pybind11/pull/2679>`_
+
+* Support ICC and NVIDIA HPC SDK in C++17 mode.
+ `#2729 <https://github.com/pybind/pybind11/pull/2729>`_
+
+* Support Intel OneAPI compiler (ICC 20.2) and add to CI.
+ `#2573 <https://github.com/pybind/pybind11/pull/2573>`_
+
+
+
v2.6.1 (Nov 11, 2020)
---------------------
@@ -14,7 +939,7 @@ v2.6.1 (Nov 11, 2020)
and ``eval`` in pure Python.
`#2616 <https://github.com/pybind/pybind11/pull/2616>`_
-* ``setup_helpers`` will no longer set a minimum macOS version lower than the
+* ``setup_helpers`` will no longer set a minimum macOS version higher than the
current version.
`#2622 <https://github.com/pybind/pybind11/pull/2622>`_
@@ -142,7 +1067,7 @@ Packaging / building improvements:
`#2338 <https://github.com/pybind/pybind11/pull/2338>`_ and
`#2370 <https://github.com/pybind/pybind11/pull/2370>`_
- * Full integration with CMake’s C++ standard system and compile features
+ * Full integration with CMake's C++ standard system and compile features
replaces ``PYBIND11_CPP_STANDARD``.
* Generated config file is now portable to different Python/compiler/CMake
@@ -374,7 +1299,7 @@ v2.4.0 (Sep 19, 2019)
`#1888 <https://github.com/pybind/pybind11/pull/1888>`_.
* ``py::details::overload_cast_impl`` is available in C++11 mode, can be used
- like ``overload_cast`` with an additional set of parantheses.
+ like ``overload_cast`` with an additional set of parentheses.
`#1581 <https://github.com/pybind/pybind11/pull/1581>`_.
* Fixed ``get_include()`` on Conda.
@@ -696,6 +1621,7 @@ v2.2.0 (August 31, 2017)
from cpp_module import CppBase1, CppBase2
+
class PyDerived(CppBase1, CppBase2):
def __init__(self):
CppBase1.__init__(self) # C++ bases must be initialized explicitly
@@ -908,7 +1834,7 @@ v2.2.0 (August 31, 2017)
* Intel C++ compiler compatibility fixes.
`#937 <https://github.com/pybind/pybind11/pull/937>`_.
-* Fixed implicit conversion of `py::enum_` to integer types on Python 2.7.
+* Fixed implicit conversion of ``py::enum_`` to integer types on Python 2.7.
`#821 <https://github.com/pybind/pybind11/pull/821>`_.
* Added ``py::hash`` to fetch the hash value of Python objects, and
diff --git a/3rdparty/pybind11/docs/classes.rst b/3rdparty/pybind11/docs/classes.rst
index f3610ef3..c0c53135 100644
--- a/3rdparty/pybind11/docs/classes.rst
+++ b/3rdparty/pybind11/docs/classes.rst
@@ -44,14 +44,14 @@ interactive Python session demonstrating this example is shown below:
% python
>>> import example
- >>> p = example.Pet('Molly')
+ >>> p = example.Pet("Molly")
>>> print(p)
<example.Pet object at 0x10cd98060>
>>> p.getName()
- u'Molly'
- >>> p.setName('Charly')
+ 'Molly'
+ >>> p.setName("Charly")
>>> p.getName()
- u'Charly'
+ 'Charly'
.. seealso::
@@ -122,12 +122,12 @@ This makes it possible to write
.. code-block:: pycon
- >>> p = example.Pet('Molly')
+ >>> p = example.Pet("Molly")
>>> p.name
- u'Molly'
- >>> p.name = 'Charly'
+ 'Molly'
+ >>> p.name = "Charly"
>>> p.name
- u'Charly'
+ 'Charly'
Now suppose that ``Pet::name`` was a private internal variable
that can only be accessed via setters and getters.
@@ -174,10 +174,10 @@ Native Python classes can pick up new attributes dynamically:
.. code-block:: pycon
>>> class Pet:
- ... name = 'Molly'
+ ... name = "Molly"
...
>>> p = Pet()
- >>> p.name = 'Charly' # overwrite existing
+ >>> p.name = "Charly" # overwrite existing
>>> p.age = 2 # dynamically add a new attribute
By default, classes exported from C++ do not support this and the only writable
@@ -195,7 +195,7 @@ Trying to set any other attribute results in an error:
.. code-block:: pycon
>>> p = example.Pet()
- >>> p.name = 'Charly' # OK, attribute defined in C++
+ >>> p.name = "Charly" # OK, attribute defined in C++
>>> p.age = 2 # fail
AttributeError: 'Pet' object has no attribute 'age'
@@ -213,7 +213,7 @@ Now everything works as expected:
.. code-block:: pycon
>>> p = example.Pet()
- >>> p.name = 'Charly' # OK, overwrite value in C++
+ >>> p.name = "Charly" # OK, overwrite value in C++
>>> p.age = 2 # OK, dynamically add a new attribute
>>> p.__dict__ # just like a native Python class
{'age': 2}
@@ -280,11 +280,11 @@ expose fields and methods of both types:
.. code-block:: pycon
- >>> p = example.Dog('Molly')
+ >>> p = example.Dog("Molly")
>>> p.name
- u'Molly'
+ 'Molly'
>>> p.bark()
- u'woof!'
+ 'woof!'
The C++ classes defined above are regular non-polymorphic types with an
inheritance relationship. This is reflected in Python:
@@ -332,7 +332,7 @@ will automatically recognize this:
>>> type(p)
PolymorphicDog # automatically downcast
>>> p.bark()
- u'woof!'
+ 'woof!'
Given a pointer to a polymorphic base, pybind11 performs automatic downcasting
to the actual derived type. Note that this goes beyond the usual situation in
@@ -434,8 +434,7 @@ you can use ``py::detail::overload_cast_impl`` with an additional set of parenth
.def("set", overload_cast_<int>()(&Pet::set), "Set the pet's age")
.def("set", overload_cast_<const std::string &>()(&Pet::set), "Set the pet's name");
-.. [#cpp14] A compiler which supports the ``-std=c++14`` flag
- or Visual Studio 2015 Update 2 and newer.
+.. [#cpp14] A compiler which supports the ``-std=c++14`` flag.
.. note::
@@ -446,8 +445,7 @@ you can use ``py::detail::overload_cast_impl`` with an additional set of parenth
Enumerations and internal types
===============================
-Let's now suppose that the example class contains an internal enumeration type,
-e.g.:
+Let's now suppose that the example class contains internal types like enumerations, e.g.:
.. code-block:: cpp
@@ -457,10 +455,15 @@ e.g.:
Cat
};
+ struct Attributes {
+ float age = 0;
+ };
+
Pet(const std::string &name, Kind type) : name(name), type(type) { }
std::string name;
Kind type;
+ Attributes attr;
};
The binding code for this example looks as follows:
@@ -471,22 +474,28 @@ The binding code for this example looks as follows:
pet.def(py::init<const std::string &, Pet::Kind>())
.def_readwrite("name", &Pet::name)
- .def_readwrite("type", &Pet::type);
+ .def_readwrite("type", &Pet::type)
+ .def_readwrite("attr", &Pet::attr);
py::enum_<Pet::Kind>(pet, "Kind")
.value("Dog", Pet::Kind::Dog)
.value("Cat", Pet::Kind::Cat)
.export_values();
-To ensure that the ``Kind`` type is created within the scope of ``Pet``, the
-``pet`` :class:`class_` instance must be supplied to the :class:`enum_`.
+ py::class_<Pet::Attributes>(pet, "Attributes")
+ .def(py::init<>())
+ .def_readwrite("age", &Pet::Attributes::age);
+
+
+To ensure that the nested types ``Kind`` and ``Attributes`` are created within the scope of ``Pet``, the
+``pet`` :class:`class_` instance must be supplied to the :class:`enum_` and :class:`class_`
constructor. The :func:`enum_::export_values` function exports the enum entries
into the parent scope, which should be skipped for newer C++11-style strongly
typed enums.
.. code-block:: pycon
- >>> p = Pet('Lucy', Pet.Cat)
+ >>> p = Pet("Lucy", Pet.Cat)
>>> p.type
Kind.Cat
>>> int(p.type)
@@ -508,7 +517,7 @@ The ``name`` property returns the name of the enum value as a unicode string.
.. code-block:: pycon
- >>> p = Pet( "Lucy", Pet.Cat )
+ >>> p = Pet("Lucy", Pet.Cat)
>>> pet_type = p.type
>>> pet_type
Pet.Cat
diff --git a/3rdparty/pybind11/docs/compiling.rst b/3rdparty/pybind11/docs/compiling.rst
index f26e6cf6..2b543be0 100644
--- a/3rdparty/pybind11/docs/compiling.rst
+++ b/3rdparty/pybind11/docs/compiling.rst
@@ -42,10 +42,7 @@ An example of a ``setup.py`` using pybind11's helpers:
),
]
- setup(
- ...,
- ext_modules=ext_modules
- )
+ setup(..., ext_modules=ext_modules)
If you want to do an automatic search for the highest supported C++ standard,
that is supported via a ``build_ext`` command override; it will only affect
@@ -64,11 +61,20 @@ that is supported via a ``build_ext`` command override; it will only affect
),
]
- setup(
- ...,
- cmdclass={"build_ext": build_ext},
- ext_modules=ext_modules
- )
+ setup(..., cmdclass={"build_ext": build_ext}, ext_modules=ext_modules)
+
+If you have single-file extension modules that are directly stored in the
+Python source tree (``foo.cpp`` in the same directory as where a ``foo.py``
+would be located), you can also generate ``Pybind11Extensions`` using
+``setup_helpers.intree_extensions``: ``intree_extensions(["path/to/foo.cpp",
+...])`` returns a list of ``Pybind11Extensions`` which can be passed to
+``ext_modules``, possibly after further customizing their attributes
+(``libraries``, ``include_dirs``, etc.). By doing so, a ``foo.*.so`` extension
+module will be generated and made available upon installation.
+
+``intree_extension`` will automatically detect if you are using a ``src``-style
+layout (as long as no namespace packages are involved), but you can also
+explicitly pass ``package_dir`` to it (as in ``setuptools.setup``).
Since pybind11 does not require NumPy when building, a light-weight replacement
for NumPy's parallel compilation distutils tool is included. Use it like this:
@@ -84,22 +90,23 @@ for NumPy's parallel compilation distutils tool is included. Use it like this:
The argument is the name of an environment variable to control the number of
threads, such as ``NPY_NUM_BUILD_JOBS`` (as used by NumPy), though you can set
-something different if you want. You can also pass ``default=N`` to set the
-default number of threads (0 will take the number of threads available) and
-``max=N``, the maximum number of threads; if you have a large extension you may
-want set this to a memory dependent number.
+something different if you want; ``CMAKE_BUILD_PARALLEL_LEVEL`` is another choice
+a user might expect. You can also pass ``default=N`` to set the default number
+of threads (0 will take the number of threads available) and ``max=N``, the
+maximum number of threads; if you have a large extension you may want set this
+to a memory dependent number.
If you are developing rapidly and have a lot of C++ files, you may want to
avoid rebuilding files that have not changed. For simple cases were you are
using ``pip install -e .`` and do not have local headers, you can skip the
-rebuild if a object file is newer than it's source (headers are not checked!)
+rebuild if an object file is newer than its source (headers are not checked!)
with the following:
.. code-block:: python
from pybind11.setup_helpers import ParallelCompile, naive_recompile
- SmartCompile("NPY_NUM_BUILD_JOBS", needs_recompile=naive_recompile).install()
+ ParallelCompile("NPY_NUM_BUILD_JOBS", needs_recompile=naive_recompile).install()
If you have a more complex build, you can implement a smarter function and pass
@@ -136,7 +143,7 @@ Your ``pyproject.toml`` file will likely look something like this:
.. code-block:: toml
[build-system]
- requires = ["setuptools", "wheel", "pybind11==2.6.0"]
+ requires = ["setuptools>=42", "wheel", "pybind11~=2.6.1"]
build-backend = "setuptools.build_meta"
.. note::
@@ -147,10 +154,12 @@ Your ``pyproject.toml`` file will likely look something like this:
in Python) using something like `cibuildwheel`_, remember that ``setup.py``
and ``pyproject.toml`` are not even contained in the wheel, so this high
Pip requirement is only for source builds, and will not affect users of
- your binary wheels.
+ your binary wheels. If you are building SDists and wheels, then
+ `pypa-build`_ is the recommended official tool.
.. _PEP 517: https://www.python.org/dev/peps/pep-0517/
.. _cibuildwheel: https://cibuildwheel.readthedocs.io
+.. _pypa-build: https://pypa-build.readthedocs.io/en/latest/
.. _setup_helpers-setup_requires:
@@ -331,7 +340,7 @@ standard explicitly with
set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ version selection") # or 11, 14, 17, 20
set(CMAKE_CXX_STANDARD_REQUIRED ON) # optional, ensure standard is supported
- set(CMAKE_CXX_EXTENSIONS OFF) # optional, keep compiler extensionsn off
+ set(CMAKE_CXX_EXTENSIONS OFF) # optional, keep compiler extensions off
The variables can also be set when calling CMake from the command line using
the ``-D<variable>=<value>`` flag. You can also manually set ``CXX_STANDARD``
@@ -401,16 +410,17 @@ can refer to the same [cmake_example]_ repository for a full sample project
FindPython mode
---------------
-CMake 3.12+ (3.15+ recommended) added a new module called FindPython that had a
-highly improved search algorithm and modern targets and tools. If you use
-FindPython, pybind11 will detect this and use the existing targets instead:
+CMake 3.12+ (3.15+ recommended, 3.18.2+ ideal) added a new module called
+FindPython that had a highly improved search algorithm and modern targets
+and tools. If you use FindPython, pybind11 will detect this and use the
+existing targets instead:
.. code-block:: cmake
- cmake_minumum_required(VERSION 3.15...3.18)
+ cmake_minimum_required(VERSION 3.15...3.22)
project(example LANGUAGES CXX)
- find_package(Python COMPONENTS Interpreter Development REQUIRED)
+ find_package(Python 3.6 COMPONENTS Interpreter Development REQUIRED)
find_package(pybind11 CONFIG REQUIRED)
# or add_subdirectory(pybind11)
@@ -423,9 +433,8 @@ algorithms from the CMake invocation, with ``-DPYBIND11_FINDPYTHON=ON``.
.. warning::
- If you use FindPython2 and FindPython3 to dual-target Python, use the
- individual targets listed below, and avoid targets that directly include
- Python parts.
+ If you use FindPython to multi-target Python versions, use the individual
+ targets listed below, and avoid targets that directly include Python parts.
There are `many ways to hint or force a discovery of a specific Python
installation <https://cmake.org/cmake/help/latest/module/FindPython.html>`_),
@@ -433,6 +442,14 @@ setting ``Python_ROOT_DIR`` may be the most common one (though with
virtualenv/venv support, and Conda support, this tends to find the correct
Python version more often than the old system did).
+.. warning::
+
+ When the Python libraries (i.e. ``libpythonXX.a`` and ``libpythonXX.so``
+ on Unix) are not available, as is the case on a manylinux image, the
+ ``Development`` component will not be resolved by ``FindPython``. When not
+ using the embedding functionality, CMake 3.18+ allows you to specify
+ ``Development.Module`` instead of ``Development`` to resolve this issue.
+
.. versionadded:: 2.6
Advanced: interface library targets
@@ -444,11 +461,8 @@ available in all modes. The targets provided are:
``pybind11::headers``
Just the pybind11 headers and minimum compile requirements
- ``pybind11::python2_no_register``
- Quiets the warning/error when mixing C++14 or higher and Python 2
-
``pybind11::pybind11``
- Python headers + ``pybind11::headers`` + ``pybind11::python2_no_register`` (Python 2 only)
+ Python headers + ``pybind11::headers``
``pybind11::python_link_helper``
Just the "linking" part of pybind11:module
@@ -457,7 +471,7 @@ available in all modes. The targets provided are:
Everything for extension modules - ``pybind11::pybind11`` + ``Python::Module`` (FindPython CMake 3.15+) or ``pybind11::python_link_helper``
``pybind11::embed``
- Everything for embedding the Python interpreter - ``pybind11::pybind11`` + ``Python::Embed`` (FindPython) or Python libs
+ Everything for embedding the Python interpreter - ``pybind11::pybind11`` + ``Python::Python`` (FindPython) or Python libs
``pybind11::lto`` / ``pybind11::thin_lto``
An alternative to `INTERPROCEDURAL_OPTIMIZATION` for adding link-time optimization.
@@ -491,7 +505,10 @@ You can use these targets to build complex applications. For example, the
target_link_libraries(example PRIVATE pybind11::module pybind11::lto pybind11::windows_extras)
pybind11_extension(example)
- pybind11_strip(example)
+ if(NOT MSVC AND NOT ${CMAKE_BUILD_TYPE} MATCHES Debug|RelWithDebInfo)
+ # Strip unnecessary sections of the binary on Linux/macOS
+ pybind11_strip(example)
+ endif()
set_target_properties(example PROPERTIES CXX_VISIBILITY_PRESET "hidden"
CUDA_VISIBILITY_PRESET "hidden")
@@ -504,7 +521,7 @@ Instead of setting properties, you can set ``CMAKE_*`` variables to initialize t
compiler flags are provided to ensure high quality code generation. In
contrast to the ``pybind11_add_module()`` command, the CMake interface
provides a *composable* set of targets to ensure that you retain flexibility.
- It can be expecially important to provide or set these properties; the
+ It can be especially important to provide or set these properties; the
:ref:`FAQ <faq:symhidden>` contains an explanation on why these are needed.
.. versionadded:: 2.6
@@ -557,10 +574,7 @@ On Linux, you can compile an example such as the one given in
.. code-block:: bash
- $ c++ -O3 -Wall -shared -std=c++11 -fPIC `python3 -m pybind11 --includes` example.cpp -o example`python3-config --extension-suffix`
-
-The flags given here assume that you're using Python 3. For Python 2, just
-change the executable appropriately (to ``python`` or ``python2``).
+ $ c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) example.cpp -o example$(python3-config --extension-suffix)
The ``python3 -m pybind11 --includes`` command fetches the include paths for
both pybind11 and Python headers. This assumes that pybind11 has been installed
@@ -568,19 +582,13 @@ using ``pip`` or ``conda``. If it hasn't, you can also manually specify
``-I <path-to-pybind11>/include`` together with the Python includes path
``python3-config --includes``.
-Note that Python 2.7 modules don't use a special suffix, so you should simply
-use ``example.so`` instead of ``example`python3-config --extension-suffix```.
-Besides, the ``--extension-suffix`` option may or may not be available, depending
-on the distribution; in the latter case, the module extension can be manually
-set to ``.so``.
-
On macOS: the build command is almost the same but it also requires passing
the ``-undefined dynamic_lookup`` flag so as to ignore missing symbols when
building the module:
.. code-block:: bash
- $ c++ -O3 -Wall -shared -std=c++11 -undefined dynamic_lookup `python3 -m pybind11 --includes` example.cpp -o example`python3-config --extension-suffix`
+ $ c++ -O3 -Wall -shared -std=c++11 -undefined dynamic_lookup $(python3 -m pybind11 --includes) example.cpp -o example$(python3-config --extension-suffix)
In general, it is advisable to include several additional build parameters
that can considerably reduce the size of the created binary. Refer to section
diff --git a/3rdparty/pybind11/docs/conf.py b/3rdparty/pybind11/docs/conf.py
index 66db310e..2da6773f 100644
--- a/3rdparty/pybind11/docs/conf.py
+++ b/3rdparty/pybind11/docs/conf.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
#
# pybind11 documentation build configuration file, created by
# sphinx-quickstart on Sun Oct 11 19:23:48 2015.
@@ -13,12 +12,11 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
-import sys
import os
-import shlex
+import re
import subprocess
+import sys
from pathlib import Path
-import re
DIR = Path(__file__).parent.resolve()
@@ -37,6 +35,7 @@ DIR = Path(__file__).parent.resolve()
# ones.
extensions = [
"breathe",
+ "sphinx_copybutton",
"sphinxcontrib.rsvgconverter",
"sphinxcontrib.moderncmakedomain",
]
@@ -127,23 +126,7 @@ todo_include_todos = False
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
-on_rtd = os.environ.get("READTHEDOCS", None) == "True"
-
-if not on_rtd: # only import and set the theme if we're building docs locally
- import sphinx_rtd_theme
-
- html_theme = "sphinx_rtd_theme"
- html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
-
- html_context = {"css_files": ["_static/theme_overrides.css"]}
-else:
- html_context = {
- "css_files": [
- "//media.readthedocs.org/css/sphinx_rtd_theme.css",
- "//media.readthedocs.org/css/readthedocs-doc-embed.css",
- "_static/theme_overrides.css",
- ]
- }
+html_theme = "furo"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
@@ -174,6 +157,10 @@ else:
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
+html_css_files = [
+ "css/custom.css",
+]
+
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
@@ -239,6 +226,8 @@ htmlhelp_basename = "pybind11doc"
# -- Options for LaTeX output ---------------------------------------------
+latex_engine = "pdflatex"
+
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
@@ -344,17 +333,20 @@ def generate_doxygen_xml(app):
subprocess.call(["doxygen", "--version"])
retcode = subprocess.call(["doxygen"], cwd=app.confdir)
if retcode < 0:
- sys.stderr.write("doxygen error code: {}\n".format(-retcode))
+ sys.stderr.write(f"doxygen error code: {-retcode}\n")
except OSError as e:
- sys.stderr.write("doxygen execution failed: {}\n".format(e))
+ sys.stderr.write(f"doxygen execution failed: {e}\n")
def prepare(app):
with open(DIR.parent / "README.rst") as f:
contents = f.read()
- # Filter out section titles for index.rst for LaTeX
if app.builder.name == "latex":
+ # Remove badges and stuff from start
+ contents = contents[contents.find(r".. start") :]
+
+ # Filter out section titles for index.rst for LaTeX
contents = re.sub(r"^(.*)\n[-~]{3,}$", r"**\1**", contents, flags=re.MULTILINE)
with open(DIR / "readme.rst", "w") as f:
diff --git a/3rdparty/pybind11/docs/faq.rst b/3rdparty/pybind11/docs/faq.rst
index 8bf05a40..28498e7d 100644
--- a/3rdparty/pybind11/docs/faq.rst
+++ b/3rdparty/pybind11/docs/faq.rst
@@ -5,12 +5,10 @@ Frequently asked questions
===========================================================
1. Make sure that the name specified in PYBIND11_MODULE is identical to the
-filename of the extension library (without suffixes such as .so)
+filename of the extension library (without suffixes such as ``.so``).
2. If the above did not fix the issue, you are likely using an incompatible
-version of Python (for instance, the extension library was compiled against
-Python 2, while the interpreter is running on top of some version of Python
-3, or vice versa).
+version of Python that does not match what you compiled with.
"Symbol not found: ``__Py_ZeroStruct`` / ``_PyInstanceMethod_Type``"
========================================================================
@@ -54,7 +52,7 @@ provided by the caller -- in fact, it does nothing at all.
.. code-block:: python
def increment(i):
- i += 1 # nope..
+ i += 1 # nope..
pybind11 is also affected by such language-level conventions, which means that
binding ``increment`` or ``increment_ptr`` will also create Python functions
@@ -147,7 +145,7 @@ using C++14 template metaprogramming.
.. _`faq:hidden_visibility`:
-"‘SomeClass’ declared with greater visibility than the type of its field ‘SomeClass::member’ [-Wattributes]"
+"'SomeClass' declared with greater visibility than the type of its field 'SomeClass::member' [-Wattributes]"
============================================================================================================
This error typically indicates that you are compiling without the required
@@ -169,8 +167,8 @@ can be changed, but even if it isn't it is not always enough to guarantee
complete independence of the symbols involved when not using
``-fvisibility=hidden``.
-Additionally, ``-fvisiblity=hidden`` can deliver considerably binary size
-savings. (See the following section for more details).
+Additionally, ``-fvisibility=hidden`` can deliver considerably binary size
+savings. (See the following section for more details.)
.. _`faq:symhidden`:
@@ -180,7 +178,7 @@ How can I create smaller binaries?
To do its job, pybind11 extensively relies on a programming technique known as
*template metaprogramming*, which is a way of performing computation at compile
-time using type information. Template metaprogamming usually instantiates code
+time using type information. Template metaprogramming usually instantiates code
involving significant numbers of deeply nested types that are either completely
removed or reduced to just a few instructions during the compiler's optimization
phase. However, due to the nested nature of these types, the resulting symbol
@@ -222,20 +220,6 @@ In addition to decreasing binary size, ``-fvisibility=hidden`` also avoids
potential serious issues when loading multiple modules and is required for
proper pybind operation. See the previous FAQ entry for more details.
-Working with ancient Visual Studio 2008 builds on Windows
-=========================================================
-
-The official Windows distributions of Python are compiled using truly
-ancient versions of Visual Studio that lack good C++11 support. Some users
-implicitly assume that it would be impossible to load a plugin built with
-Visual Studio 2015 into a Python distribution that was compiled using Visual
-Studio 2008. However, no such issue exists: it's perfectly legitimate to
-interface DLLs that are built with different compilers and/or C libraries.
-Common gotchas to watch out for involve not ``free()``-ing memory region
-that that were ``malloc()``-ed in another shared library, using data
-structures with incompatible ABIs, and so on. pybind11 is very careful not
-to make these types of mistakes.
-
How can I properly handle Ctrl-C in long-running functions?
===========================================================
@@ -289,27 +273,7 @@ Conflicts can arise, however, when using pybind11 in a project that *also* uses
the CMake Python detection in a system with several Python versions installed.
This difference may cause inconsistencies and errors if *both* mechanisms are
-used in the same project. Consider the following CMake code executed in a
-system with Python 2.7 and 3.x installed:
-
-.. code-block:: cmake
-
- find_package(PythonInterp)
- find_package(PythonLibs)
- find_package(pybind11)
-
-It will detect Python 2.7 and pybind11 will pick it as well.
-
-In contrast this code:
-
-.. code-block:: cmake
-
- find_package(pybind11)
- find_package(PythonInterp)
- find_package(PythonLibs)
-
-will detect Python 3.x for pybind11 and may crash on
-``find_package(PythonLibs)`` afterwards.
+used in the same project.
There are three possible solutions:
diff --git a/3rdparty/pybind11/docs/installing.rst b/3rdparty/pybind11/docs/installing.rst
index 25972859..30b9f185 100644
--- a/3rdparty/pybind11/docs/installing.rst
+++ b/3rdparty/pybind11/docs/installing.rst
@@ -8,6 +8,8 @@ There are several ways to get the pybind11 source, which lives at
developers recommend one of the first three ways listed here, submodule, PyPI,
or conda-forge, for obtaining pybind11.
+.. _include_as_a_submodule:
+
Include as a submodule
======================
@@ -16,7 +18,7 @@ as a submodule. From your git repository, use:
.. code-block:: bash
- git submodule add ../../pybind/pybind11 extern/pybind11 -b stable
+ git submodule add -b stable ../../pybind/pybind11 extern/pybind11
git submodule update --init
This assumes you are placing your dependencies in ``extern/``, and that you are
diff --git a/3rdparty/pybind11/docs/limitations.rst b/3rdparty/pybind11/docs/limitations.rst
index be7300cd..def5ad65 100644
--- a/3rdparty/pybind11/docs/limitations.rst
+++ b/3rdparty/pybind11/docs/limitations.rst
@@ -57,16 +57,16 @@ clean, well written patch would likely be accepted to solve them.
Python 3.9.0 warning
^^^^^^^^^^^^^^^^^^^^
-Combining older versions of pybind11 (< 2.6.0) with Python on 3.9.0 will
-trigger undefined behavior that typically manifests as crashes during
+Combining older versions of pybind11 (< 2.6.0) with Python on exactly 3.9.0
+will trigger undefined behavior that typically manifests as crashes during
interpreter shutdown (but could also destroy your data. **You have been
warned**).
-This issue has been
-`fixed in Python <https://github.com/python/cpython/pull/22670>`_. As a
-mitigation until 3.9.1 is released and commonly used, pybind11 (2.6.0 or newer)
-includes a temporary workaround specifically when Python 3.9.0 is detected at
-runtime, leaking about 50 bytes of memory when a callback function is garbage
-collected. For reference; the pybind11 test suite has about 2,000 such
-callbacks, but only 49 are garbage collected before the end-of-process. Wheels
-built with Python 3.9.0 will correctly avoid the leak when run in Python 3.9.1.
+This issue was `fixed in Python <https://github.com/python/cpython/pull/22670>`_.
+As a mitigation for this bug, pybind11 2.6.0 or newer includes a workaround
+specifically when Python 3.9.0 is detected at runtime, leaking about 50 bytes
+of memory when a callback function is garbage collected. For reference, the
+pybind11 test suite has about 2,000 such callbacks, but only 49 are garbage
+collected before the end-of-process. Wheels (even if built with Python 3.9.0)
+will correctly avoid the leak when run in Python 3.9.1, and this does not
+affect other 3.X versions.
diff --git a/3rdparty/pybind11/docs/pybind11-logo.png b/3rdparty/pybind11/docs/pybind11-logo.png
index 4cbad54f..2d633a4d 100644
--- a/3rdparty/pybind11/docs/pybind11-logo.png
+++ b/3rdparty/pybind11/docs/pybind11-logo.png
Binary files differ
diff --git a/3rdparty/pybind11/docs/reference.rst b/3rdparty/pybind11/docs/reference.rst
index e3a61afb..e64a0351 100644
--- a/3rdparty/pybind11/docs/reference.rst
+++ b/3rdparty/pybind11/docs/reference.rst
@@ -52,6 +52,20 @@ Convenience classes for specific Python types
.. doxygengroup:: pytypes
:members:
+Convenience functions converting to Python types
+================================================
+
+.. doxygenfunction:: make_tuple(Args&&...)
+
+.. doxygenfunction:: make_iterator(Iterator, Sentinel, Extra &&...)
+.. doxygenfunction:: make_iterator(Type &, Extra&&...)
+
+.. doxygenfunction:: make_key_iterator(Iterator, Sentinel, Extra &&...)
+.. doxygenfunction:: make_key_iterator(Type &, Extra&&...)
+
+.. doxygenfunction:: make_value_iterator(Iterator, Sentinel, Extra &&...)
+.. doxygenfunction:: make_value_iterator(Type &, Extra&&...)
+
.. _extras:
Passing extra arguments to ``def`` or ``class_``
@@ -110,7 +124,6 @@ Exceptions
.. doxygenclass:: builtin_exception
:members:
-
Literals
========
diff --git a/3rdparty/pybind11/docs/release.rst b/3rdparty/pybind11/docs/release.rst
index 43f502a1..e761cdf7 100644
--- a/3rdparty/pybind11/docs/release.rst
+++ b/3rdparty/pybind11/docs/release.rst
@@ -15,26 +15,37 @@ For example:
For beta, ``PYBIND11_VERSION_PATCH`` should be ``Z.b1``. RC's can be ``Z.rc1``.
Always include the dot (even though PEP 440 allows it to be dropped). For a
-final release, this must be a simple integer.
+final release, this must be a simple integer. There is also a HEX version of
+the version just below.
To release a new version of pybind11:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+If you don't have nox, you should either use ``pipx run nox`` instead, or use
+``pipx install nox`` or ``brew install nox`` (Unix).
+
- Update the version number
- - Update ``PYBIND11_VERSION_MAJOR`` etc. in
- ``include/pybind11/detail/common.h``. PATCH should be a simple integer.
- - Update ``pybind11/_version.py`` (match above)
- - Ensure that all the information in ``setup.py`` is up-to-date.
- - Add release date in ``docs/changelog.rst``.
- - ``git add`` and ``git commit``, ``git push``. **Ensure CI passes**. (If it
- fails due to a known flake issue, either ignore or restart CI.)
-- Add a release branch if this is a new minor version
- - ``git checkout -b vX.Y``, ``git push -u origin vX.Y``
+ - Update ``PYBIND11_VERSION_MAJOR`` etc. in
+ ``include/pybind11/detail/common.h``. PATCH should be a simple integer.
+ - Update the version HEX just below, as well.
+ - Update ``pybind11/_version.py`` (match above)
+ - Run ``nox -s tests_packaging`` to ensure this was done correctly.
+ - Ensure that all the information in ``setup.cfg`` is up-to-date, like
+ supported Python versions.
+ - Add release date in ``docs/changelog.rst``.
+ - Check to make sure
+ `needs-changelog <https://github.com/pybind/pybind11/pulls?q=is%3Apr+is%3Aclosed+label%3A%22needs+changelog%22>`_
+ issues are entered in the changelog (clear the label when done).
+ - ``git add`` and ``git commit``, ``git push``. **Ensure CI passes**. (If it
+ fails due to a known flake issue, either ignore or restart CI.)
+- Add a release branch if this is a new minor version, or update the existing release branch if it is a patch version
+ - New branch: ``git checkout -b vX.Y``, ``git push -u origin vX.Y``
+ - Update branch: ``git checkout vX.Y``, ``git merge <release branch>``, ``git push``
- Update tags (optional; if you skip this, the GitHub release makes a
- non-annotated tag for you)
- - ``git tag -a vX.Y.Z -m 'vX.Y.Z release'``.
- - ``git push --tags``.
+ non-annotated tag for you)
+ - ``git tag -a vX.Y.Z -m 'vX.Y.Z release'``.
+ - ``git push --tags``.
- Update stable
- ``git checkout stable``
- ``git merge master``
@@ -42,25 +53,36 @@ To release a new version of pybind11:
- Make a GitHub release (this shows up in the UI, sends new release
notifications to users watching releases, and also uploads PyPI packages).
(Note: if you do not use an existing tag, this creates a new lightweight tag
- for you, so you could skip the above step).
- - GUI method: click "Create a new release" on the far right, fill in the tag
- name (if you didn't tag above, it will be made here), fill in a release
- name like "Version X.Y.Z", and optionally copy-and-paste the changelog into
- the description (processed as markdown by Pandoc). Check "pre-release" if
- this is a beta/RC.
- - CLI method: with ``gh`` installed, run ``gh release create vX.Y.Z -t "Version X.Y.Z"``
- If this is a pre-release, add ``-p``.
+ for you, so you could skip the above step.)
+ - GUI method: Under `releases <https://github.com/pybind/pybind11/releases>`_
+ click "Draft a new release" on the far right, fill in the tag name
+ (if you didn't tag above, it will be made here), fill in a release name
+ like "Version X.Y.Z", and copy-and-paste the markdown-formatted (!) changelog
+ into the description (usually ``cat docs/changelog.rst | pandoc -f rst -t gfm``).
+ Check "pre-release" if this is a beta/RC.
+ - CLI method: with ``gh`` installed, run ``gh release create vX.Y.Z -t "Version X.Y.Z"``
+ If this is a pre-release, add ``-p``.
- Get back to work
- - Make sure you are on master, not somewhere else: ``git checkout master``
- - Update version macros in ``include/pybind11/detail/common.h`` (set PATCH to
- ``0.dev1`` and increment MINOR).
- - Update ``_version.py`` to match
- - Add a plot for in-development updates in ``docs/changelog.rst``.
- - ``git add``, ``git commit``, ``git push``
+ - Make sure you are on master, not somewhere else: ``git checkout master``
+ - Update version macros in ``include/pybind11/detail/common.h`` (set PATCH to
+ ``0.dev1`` and increment MINOR).
+ - Update ``_version.py`` to match
+ - Run ``nox -s tests_packaging`` to ensure this was done correctly.
+ - Add a spot for in-development updates in ``docs/changelog.rst``.
+ - ``git add``, ``git commit``, ``git push``
If a version branch is updated, remember to set PATCH to ``1.dev1``.
+If you'd like to bump homebrew, run:
+
+.. code-block:: console
+
+ brew bump-formula-pr --url https://github.com/pybind/pybind11/archive/vX.Y.Z.tar.gz
+
+Conda-forge should automatically make a PR in a few hours, and automatically
+merge it if there are no issues.
+
Manual packaging
^^^^^^^^^^^^^^^^
@@ -69,9 +91,7 @@ If you need to manually upload releases, you can download the releases from the
.. code-block:: bash
- python3 -m pip install build
- python3 -m build
- PYBIND11_SDIST_GLOBAL=1 python3 -m build
+ nox -s build
twine upload dist/*
This makes SDists and wheels, and the final line uploads them.
diff --git a/3rdparty/pybind11/docs/requirements.txt b/3rdparty/pybind11/docs/requirements.txt
index 35366e3c..d2a9ae16 100644
--- a/3rdparty/pybind11/docs/requirements.txt
+++ b/3rdparty/pybind11/docs/requirements.txt
@@ -1,7 +1,6 @@
-breathe==4.20.0
-commonmark==0.9.1
-recommonmark==0.6.0
-sphinx==3.2.1
-sphinx_rtd_theme==0.5.0
-sphinxcontrib-moderncmakedomain==3.13
-sphinxcontrib-svg2pdfconverter==1.1.0
+breathe==4.34.0
+furo==2022.6.21
+sphinx==5.0.2
+sphinx-copybutton==0.5.0
+sphinxcontrib-moderncmakedomain==3.21.4
+sphinxcontrib-svg2pdfconverter==1.2.0
diff --git a/3rdparty/pybind11/docs/upgrade.rst b/3rdparty/pybind11/docs/upgrade.rst
index 87bcebee..6a9db2d0 100644
--- a/3rdparty/pybind11/docs/upgrade.rst
+++ b/3rdparty/pybind11/docs/upgrade.rst
@@ -8,6 +8,46 @@ to a new version. But it goes into more detail. This includes things like
deprecated APIs and their replacements, build system changes, general code
modernization and other useful information.
+.. _upgrade-guide-2.9:
+
+v2.9
+====
+
+* Any usage of the recently added ``py::make_simple_namespace`` should be
+ converted to using ``py::module_::import("types").attr("SimpleNamespace")``
+ instead.
+
+* The use of ``_`` in custom type casters can now be replaced with the more
+ readable ``const_name`` instead. The old ``_`` shortcut has been retained
+ unless it is being used as a macro (like for gettext).
+
+
+.. _upgrade-guide-2.7:
+
+v2.7
+====
+
+*Before* v2.7, ``py::str`` can hold ``PyUnicodeObject`` or ``PyBytesObject``,
+and ``py::isinstance<str>()`` is ``true`` for both ``py::str`` and
+``py::bytes``. Starting with v2.7, ``py::str`` exclusively holds
+``PyUnicodeObject`` (`#2409 <https://github.com/pybind/pybind11/pull/2409>`_),
+and ``py::isinstance<str>()`` is ``true`` only for ``py::str``. To help in
+the transition of user code, the ``PYBIND11_STR_LEGACY_PERMISSIVE`` macro
+is provided as an escape hatch to go back to the legacy behavior. This macro
+will be removed in future releases. Two types of required fixes are expected
+to be common:
+
+* Accidental use of ``py::str`` instead of ``py::bytes``, masked by the legacy
+ behavior. These are probably very easy to fix, by changing from
+ ``py::str`` to ``py::bytes``.
+
+* Reliance on py::isinstance<str>(obj) being ``true`` for
+ ``py::bytes``. This is likely to be easy to fix in most cases by adding
+ ``|| py::isinstance<bytes>(obj)``, but a fix may be more involved, e.g. if
+ ``py::isinstance<T>`` appears in a template. Such situations will require
+ careful review and custom fixes.
+
+
.. _upgrade-guide-2.6:
v2.6
@@ -192,7 +232,7 @@ way to get and set object state. See :ref:`pickling` for details.
...
.def(py::pickle(
[](const Foo &self) { // __getstate__
- return py::make_tuple(f.value1(), f.value2(), ...); // unchanged
+ return py::make_tuple(self.value1(), self.value2(), ...); // unchanged
},
[](py::tuple t) { // __setstate__, note: no `self` argument
return new Foo(t[0].cast<std::string>(), ...);
@@ -256,7 +296,7 @@ Within pybind11's CMake build system, ``pybind11_add_module`` has always been
setting the ``-fvisibility=hidden`` flag in release mode. From now on, it's
being applied unconditionally, even in debug mode and it can no longer be opted
out of with the ``NO_EXTRAS`` option. The ``pybind11::module`` target now also
-adds this flag to it's interface. The ``pybind11::embed`` target is unchanged.
+adds this flag to its interface. The ``pybind11::embed`` target is unchanged.
The most significant change here is for the ``pybind11::module`` target. If you
were previously relying on default visibility, i.e. if your Python module was
@@ -484,7 +524,7 @@ include a declaration of the form:
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>)
-Continuing to do so won’t cause an error or even a deprecation warning,
+Continuing to do so won't cause an error or even a deprecation warning,
but it's completely redundant.