pybind11 — Seamless operability between C++11 and Python

Overview
pybind11 logo

pybind11 — Seamless operability between C++11 and Python

Latest Documentation Status Stable Documentation Status Gitter chat GitHub Discussions CI Build status

Repology PyPI package Conda-forge Python Versions

Setuptools exampleScikit-build exampleCMake example

pybind11 is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code. Its goals and syntax are similar to the excellent Boost.Python library by David Abrahams: to minimize boilerplate code in traditional extension modules by inferring type information using compile-time introspection.

The main issue with Boost.Python—and the reason for creating such a similar project—is Boost. Boost is an enormously large and complex suite of utility libraries that works with almost every C++ compiler in existence. This compatibility has its cost: arcane template tricks and workarounds are necessary to support the oldest and buggiest of compiler specimens. Now that C++11-compatible compilers are widely available, this heavy machinery has become an excessively large and unnecessary dependency.

Think of this library as a tiny self-contained version of Boost.Python with everything stripped away that isn’t relevant for binding generation. Without comments, the core header files only require ~4K lines of code and depend on Python (2.7 or 3.5+, or PyPy) and the C++ standard library. This compact implementation was possible thanks to some of the new C++11 language features (specifically: tuples, lambda functions and variadic templates). Since its creation, this library has grown beyond Boost.Python in many ways, leading to dramatically simpler binding code in many common situations.

Tutorial and reference documentation is provided at pybind11.readthedocs.io. A PDF version of the manual is available here. And the source code is always available at github.com/pybind/pybind11.

Core features

pybind11 can map the following core C++ features to Python:

  • Functions accepting and returning custom data structures per value, reference, or pointer
  • Instance methods and static methods
  • Overloaded functions
  • Instance attributes and static attributes
  • Arbitrary exception types
  • Enumerations
  • Callbacks
  • Iterators and ranges
  • Custom operators
  • Single and multiple inheritance
  • STL data structures
  • Smart pointers with reference counting like std::shared_ptr
  • Internal references with correct reference counting
  • C++ classes with virtual (and pure virtual) methods can be extended in Python

Goodies

In addition to the core functionality, pybind11 provides some extra goodies:

  • Python 2.7, 3.5+, and PyPy/PyPy3 7.3 are supported with an implementation-agnostic interface.
  • It is possible to bind C++11 lambda functions with captured variables. The lambda capture data is stored inside the resulting Python function object.
  • pybind11 uses C++11 move constructors and move assignment operators whenever possible to efficiently transfer custom data types.
  • It’s easy to expose the internal storage of custom data types through Pythons’ buffer protocols. This is handy e.g. for fast conversion between C++ matrix classes like Eigen and NumPy without expensive copy operations.
  • pybind11 can automatically vectorize functions so that they are transparently applied to all entries of one or more NumPy array arguments.
  • Python's slice-based access and assignment operations can be supported with just a few lines of code.
  • Everything is contained in just a few header files; there is no need to link against any additional libraries.
  • Binaries are generally smaller by a factor of at least 2 compared to equivalent bindings generated by Boost.Python. A recent pybind11 conversion of PyRosetta, an enormous Boost.Python binding project, reported a binary size reduction of 5.4x and compile time reduction by 5.8x.
  • Function signatures are precomputed at compile time (using constexpr), leading to smaller binaries.
  • With little extra effort, C++ types can be pickled and unpickled similar to regular Python objects.

Supported compilers

  1. Clang/LLVM 3.3 or newer (for Apple Xcode’s clang, this is 5.0.0 or newer)
  2. GCC 4.8 or newer
  3. Microsoft Visual Studio 2015 Update 3 or newer
  4. Intel classic C++ compiler 18 or newer (ICC 20.2 tested in CI)
  5. Cygwin/GCC (previously tested on 2.5.1)
  6. NVCC (CUDA 11.0 tested in CI)
  7. NVIDIA PGI (20.9 tested in CI)

About

This project was created by Wenzel Jakob. Significant features and/or improvements to the code were contributed by Jonas Adler, Lori A. Burns, Sylvain Corlay, Eric Cousineau, Aaron Gokaslan, Ralf Grosse-Kunstleve, Trent Houliston, Axel Huebl, @hulucc, Yannick Jadoul, Sergey Lyskov Johan Mabille, Tomasz Miąsko, Dean Moldovan, Ben Pritchard, Jason Rhinelander, Boris Schäling, Pim Schellart, Henry Schreiner, Ivan Smirnov, Boris Staletic, and Patrick Stewart.

We thank Google for a generous financial contribution to the continuous integration infrastructure used by this project.

Contributing

See the contributing guide for information on building and contributing to pybind11.

License

pybind11 is provided under a BSD-style license that can be found in the LICENSE file. By using, distributing, or contributing to this project, you agree to the terms and conditions of this license.

Comments
  • error_already_set::what() is now constructed lazily

    error_already_set::what() is now constructed lazily

    The original motivation for this PR was a performance optimization. See the original PR description below.

    After nearly 3 years, work on this PR has led to a few related but distinct behavior changes:

    • Already merged PR #3971 — Fixes formatting of messages for originally unnormalized Python errors.
    • Already merged PR #3982

    This PR:

    • Secondary errors during normalization of the Python error are clearly reported (see test_flaky_exception_failure_point_init in test_exceptions.py).
    • Secondary errors obtaining the error message are clearly reported (see test_flaky_exception_failure_point_str in test_exceptions.py).
    • Calling error_already_set::restore() multiple times is clearly reported (preempts accidentally clearing an error, or accidentally restoring the same error twice; see test_error_already_set_double_restore in test_exceptions.py).
    • The error_already_set copy constructor is no longer racy.
    • detail::error_string() no longer restores the error message. This fixes (in practice inconsequential) bugs in detail/class.h.

    The performance gain for exceptions with long tracebacks can be very substantial. See https://github.com/pybind/pybind11/pull/1895#issuecomment-1127700599 for concrete numbers.

    A review of the error_already_set development history is under https://github.com/pybind/pybind11/pull/1895#issuecomment-1134206370.


    Original PR description below

    Prior to this PR throwing error_already_set was expensive due to the eager construction of the error string. The PR changes error_already_set::what to construct the error string on first call.

    Before:

    1.7 µs ± 9.03 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

    After:

    1.14 µs ± 1.93 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)

    Benchmark:

    const py::int_ foo() {
        py::dict d;
        try {
            return d["foo"];
        } catch (const py::error_already_set &) {
            return py::int_(42);
        }    
    }
    
    PYBIND11_MODULE(foo, m) {
      m.def("foo", &foo);
    }
    

    Note that the running time of the benchmark is dominated by stack unwinding, therefore the speedup is only ~30%.

    Suggested changelog entry:

    ``error_already_set`` is now safer and more performant, especially for exceptions with long tracebacks.
    
    opened by superbobry 111
  • Add `Eigen::Tensor` & `Eigen::TensorMap` support

    Add `Eigen::Tensor` & `Eigen::TensorMap` support

    Description

    Adds Eigen::Tensor support to eigen.h.

    Eigen::Tensor allows you to handle np.arrays with more than two dimensions, which is quite handy in many cases.

    I also added tests for all the relevant behavior.

    Note that the Eigen::TensorMap implementation could be better if we allow std::optional, but I'm not sure if we are allowed to require that in this codebase.

    Closes #1377 Closes #2119

    Suggested changelog entry:

    pybind11/eigen/tensor.h`` adds converters to and from `Eigen::Tensor` and `Eigen::TensorMap`
    
    opened by Lalaland 109
  • Add `PYBIND11_SIMPLE_GIL_MANAGEMENT` option (cmake, C++ define)

    Add `PYBIND11_SIMPLE_GIL_MANAGEMENT` option (cmake, C++ define)

    Description

    This PR adds a PYBIND11_SIMPLE_GIL_MANAGEMENT option (cmake, C++ define). The new option may be useful to try when debugging GIL-related issues, to determine if the more complex default implementation is or is not to blame. See comments here for background.

    This PR was triggered by https://github.com/pytorch/pytorch/issues/83101. While we could not reproduce the original problem in a unit test, many tests were added to test_gil_scoped.py trying to do so. That work exposed that test_gil_scoped.py has been finding deadlocks for a long time (years), but those were thus far ignored as "flakes". test_gil_scoped.py was updated to make it crystal clear when a DEADLOCK is detected. It turns out deadlocks are detected at a fairly high rate (ballpark 1 in 1000). This needs to be worked on separately. To not continue to pollute the CI results in the meantime, SKIP_IF_DEADLOCK = True was added in test_gil_scoped.py. The GitHub Actions CI logs can be harvested in the future to determine what platforms exactly are affected, and at what rate. Hopefully the information accumulating over time will lead to a better understanding and fixes, so that SKIP_IF_DEADLOCK can be removed eventually.

    This PR also adds ThreadSanitizer compatibility to test_gil_scoped.py (closes #2754).

    WARNING: Please be careful to not create ODR violations when using the new option: everything that is linked together with mutual symbol visibility needs to be rebuilt.

    Suggested changelog entry:

    * A `PYBIND11_SIMPLE_GIL_MANAGEMENT` option was added (cmake, C++ define), along with many additional tests in test_gil_scoped.py. The option may be useful to try when debugging GIL-related issues, to determine if the more complex default implementation is or is not to blame. See #4216 for background. WARNING: Please be careful to not create ODR violations when using the option: everything that is linked together with mutual symbol visibility needs to be rebuilt.
    
    opened by Chekov2k 76
  • Support NVidia HPC SDK (PGI)

    Support NVidia HPC SDK (PGI)

    In this PR:

    • Support NVidia HPC SDK with PG compilers
    • Factor out CMake filter function
    • Allow CMake to build even if pytest is missing (still shows warning)

    Closes #2214 and closes #2407.

    opened by andriish 64
  • WIP: PyPy support

    WIP: PyPy support

    This commit includes a few minor modifications to pybind11 that are needed to get simple hello-world style functions to compile and run on the latest PyPy. Types are now supported as well.

    The test suite compiles but crashes when executed.

    opened by wjakob 57
  • Intel ICC C++17 compatibility

    Intel ICC C++17 compatibility

    Adds C++17 support.

    • ICC can’t handle complex enable if’s inline, like enable_if_t<all_of<is_positional<Args>...>::value>>, but if it is refactored into a separate constexpr function, it works.
      • But MSVC doesn't like it if the function is in the return type.
    • Fold expressions cause an internal compiler error, so we have to avoid turning them on even in C++17 mode
    • Plain noexcept can cause weird errors with following syntax, noexcept(true) works fine, workaround in tests

    This also fixes the NVIDIA HPC SDK compiler in C++17 mode.

    Description

    The Intel compiler has trouble with pybind11 when compiling in C++17 mode. The first two examples in the code below result in errors like "no instance of function template [...] matches the argument list", while the third one triggers an internal compiler error.

    #include <pybind11/pybind11.h>
    
    void test1() {
      pybind11::print("Hello World");
    }
    
    void test2(pybind11::object obj) {
       obj();
    }
    
    class C {
    };
    
    void test3(pybind11::module_ &m) {
    	pybind11::class_<C>(m, "C");
    }
    

    Details can be found in #2707. @tobiasleibner implemented the fix for the template mismatch, while the workaround for the internal compiler error is mine. Part of @tobiasleibner's work went into #2573 already, which hasn't been merged yet. Since he currently doesn't have time, he suggested I post a pull request.

    Related to #2573 Fixes #2714 Fixes #2707

    Suggested changelog entry:

    * Support ICC and NVIDIA HPC SDK in C++17 mode
    
    compiler: intel 
    opened by mkuron 48
  • CMake installation path consistency

    CMake installation path consistency

    Problem:

    1. In a given installation PREFIX, pip install pybind11 or conda install pybind11 will install pybind11 headers into a new pybind11 subdirectory of the python include directory, while cmake + make install results in pybind11 headers being put into PREFIX/include/pybind11.

      For example, with a conda installation, pip will give

      PREFIX/include/pythonX.Y/pybind11 while cmake yields PREFIX/include/pybind11.

    2. It would be nice to have a consistent installation scheme between the two methods, plus the benefit of having the cmake project config files being made available, in the context of conda.

    Solution:

    This changes the destination of the headers of pybind into PYTHON_INCLUDE_DIRS/pybind11.

    The generated project config cmake files are installed in the same location as before, but reflect the new location of the headers.

    opened by SylvainCorlay 48
  • CI: Intel icc/icpc via oneAPI

    CI: Intel icc/icpc via oneAPI

    Add testing for Intel icc/icpc via the oneAPI images. Intel oneAPI is in a late beta stage, currently shipping oneAPI beta09 with ICC 20.2.

    We are adding // [workaround(intel)] near the workarounds to it will be easy to search them out later, and disable them to see if they have been fixed by the Intel compiler team.

    Here are the workarounds here:

    • py::args() -> py::args{}, in tests, regression in ICC 20+, workaround in tests
    • = default instead of {} doesn’t always work (was a recent modernization, so might have been a problem before too), workaround in tests

    Suggested changelog entry:

    * Support Intel OneAPI compiler (ICC 20.2) and add to CI.
    
    enhancement compiler: intel 
    opened by ax3l 46
  • WIP: Multiple inheritance support

    WIP: Multiple inheritance support

    This is an early snapshot of a potential way to support multiple inheritance in a minimally intrusive way. Standard single inheritance is supported using a fast fallback that matches the current implementation.

    Somewhat surprisingly, the change and related simplifications actually reduce the size of generated binaries by 4.4% :).

    There are probably a ton of cases that I didn't think of, so this is up for public review now.

    opened by wjakob 46
  • Fix cmake configuration when lto flags not available

    Fix cmake configuration when lto flags not available

    CMake current fails to run with Clang on linux:

    $ CC=clang CXX=clang++ cmake ..
    ... (various configuration) ...
    -- Configuring done
    CMake Error at tools/pybind11Tools.cmake:135 (target_compile_options):
      Error evaluating generator expression:
    
        $<:-flto>
    
      Expression did not evaluate to a known generator expression
    Call Stack (most recent call first):
      tests/CMakeLists.txt:68 (pybind11_add_module)
    

    This commit fixes the generator expressions when the lto flags are not found (they will be empty strings, but the generator expression needs a 0).

    opened by jagerman 45
  • export interface lib through `pybind11Config.cmake`

    export interface lib through `pybind11Config.cmake`

    Motivation

    Acquiring the pybind11 repo (for large projects where the pybind11_add_module isn't appropriate) is admittedly not hard either as a git submodule or as a CMake ExternalProject plus writing a Findpybind11.cmake file to search out the header location. But for the ExternalProject case, the better CMake route is to provide a pybind11Config.cmake in the installation so that consuming projects can use pre-built (installed) pybind11 without writing their own detection.

    PR Changes

    • [x] Builds a minimal interface library target (pb11) and exports it so that pybind11Config.cmake and pybind11Targets.cmake are installed along with the headers. Instructions for detection and use given in tools/pybind11Config.cmake.in
    • [x] Allows passing -DCMAKE_INSTALL_INCLUDEDIR to specify non-standard install location. Defaults to include. Note that this isn't affecting the pybind11_add_module function since it's not exporting interface include dirs.

    Questions

    • [x] Used pybind11::pybind11 for imported target name. If you want any other capitalization pattern for the project name, let me know and I'll adjust everything.
    • [x] I've hard-coded the version at 1.8, but the write_basic_package_version_file(...) four lines and the ConfigVersion.cmake installation can be commented out, if you don't want to deal with versioning in development mode.
    • I'm medium proficient at CMake, so please let me know if you see any holes in the procedure, would like some edits, or want the PR split.

    CMake Version

    • Checked that GNUInstallDirs and CMakePackageConfigHelpers present at 2.8.12 (https://gitlab.kitware.com/cmake/cmake/blob/v2.8.12/Modules/)
    • Checked that the $<INSTALL_INTERFACE generator present at 2.8.12 (https://cmake.org/cmake/help/v2.8.12/cmake.html#section_Generators)
    • Couldn't find a 2.8.12 to install, but can confirm the exported target exports at 3.0.1
    opened by loriab 45
  • [BUG]: nox -s tests -- -DCMAKE_BUILD_TYPE=Debug -DDOWNLOAD_EIGEN=OFF failed about pybind11@master on centos8_aarch64

    [BUG]: nox -s tests -- -DCMAKE_BUILD_TYPE=Debug -DDOWNLOAD_EIGEN=OFF failed about pybind11@master on centos8_aarch64

    Required prerequisites

    What version (or hash if on master) of pybind11 are you using?

    master

    Problem description

    [[email protected] spack-src]# nox -s tests -- -DCMAKE_BUILD_TYPE=Debug -DDOWNLOAD_EIGEN=OFF
    ……
    ____________________________________________________________________________ test_run_in_process_direct[_intentional_deadlock] ____________________________________________________________________________
    
    test_fn = <function _intentional_deadlock at 0xffff79cf59d0>
    
        @pytest.mark.parametrize("test_fn", ALL_BASIC_TESTS_PLUS_INTENTIONAL_DEADLOCK)
        def test_run_in_process_direct(test_fn):
            """Makes sure there is no GIL deadlock when using processes.
    
            This test is for completion, but it was never an issue.
            """
    >       assert _run_in_process(test_fn) == 0
    
    test_fn    = <function _intentional_deadlock at 0xffff79cf59d0>
    
    ../../../../tests/test_gil_scoped.py:244:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    ../../../../tests/test_gil_scoped.py:161: in _run_in_process
        process.start()
            args       = ()
            kwargs     = {}
            process    = <Process name='Process-72' parent=3362301 initial daemon>
            t_start    = 1672728059.3542063
            target     = <function _intentional_deadlock at 0xffff79cf59d0>
            test_fn    = <function _intentional_deadlock at 0xffff79cf59d0>
            timeout    = 0.1
    /home/spack/opt/spack/linux-centos8-aarch64/gcc-8.5.0/python-3.8.8-m3k3pvne56yo7wyd7a3bwf7mugupszik/lib/python3.8/multiprocessing/process.py:121: in start
        self._popen = self._Popen(self)
            self       = <Process name='Process-72' parent=3362301 initial daemon>
    /home/spack/opt/spack/linux-centos8-aarch64/gcc-8.5.0/python-3.8.8-m3k3pvne56yo7wyd7a3bwf7mugupszik/lib/python3.8/multiprocessing/context.py:224: in _Popen
        return _default_context.get_context().Process._Popen(process_obj)
            process_obj = <Process name='Process-72' parent=3362301 initial daemon>
    /home/spack/opt/spack/linux-centos8-aarch64/gcc-8.5.0/python-3.8.8-m3k3pvne56yo7wyd7a3bwf7mugupszik/lib/python3.8/multiprocessing/context.py:291: in _Popen
        return Popen(process_obj)
            Popen      = <class 'multiprocessing.popen_forkserver.Popen'>
            process_obj = <Process name='Process-72' parent=3362301 initial daemon>
    /home/spack/opt/spack/linux-centos8-aarch64/gcc-8.5.0/python-3.8.8-m3k3pvne56yo7wyd7a3bwf7mugupszik/lib/python3.8/multiprocessing/popen_forkserver.py:35: in __init__
        super().__init__(process_obj)
            __class__  = <class 'multiprocessing.popen_forkserver.Popen'>
            process_obj = <Process name='Process-72' parent=3362301 initial daemon>
            self       = <multiprocessing.popen_forkserver.Popen object at 0xffff79213eb0>
    /home/spack/opt/spack/linux-centos8-aarch64/gcc-8.5.0/python-3.8.8-m3k3pvne56yo7wyd7a3bwf7mugupszik/lib/python3.8/multiprocessing/popen_fork.py:19: in __init__
        self._launch(process_obj)
            process_obj = <Process name='Process-72' parent=3362301 initial daemon>
            self       = <multiprocessing.popen_forkserver.Popen object at 0xffff79213eb0>
    /home/spack/opt/spack/linux-centos8-aarch64/gcc-8.5.0/python-3.8.8-m3k3pvne56yo7wyd7a3bwf7mugupszik/lib/python3.8/multiprocessing/popen_forkserver.py:51: in _launch
        self.sentinel, w = forkserver.connect_to_new_process(self._fds)
            buf        = <_io.BytesIO object at 0xffffa0695220>
            prep_data  = {'authkey': b'\x84\x94\x02$\xf7\x99\xaf<:tl\xccor%\t\xf1_&\xc5\xf7W\xe0\xab\xcf5\x82C>\xc1\x8a\xfd', 'dir': '/home/sta...r5rgfkal5y2/spack-src/.nox/tests-3-8/tmp/tests', 'init_main_from_name': 'pytest.__main__', 'log_to_stderr': False, ...}
            process_obj = <Process name='Process-72' parent=3362301 initial daemon>
            self       = <multiprocessing.popen_forkserver.Popen object at 0xffff79213eb0>
    /home/spack/opt/spack/linux-centos8-aarch64/gcc-8.5.0/python-3.8.8-m3k3pvne56yo7wyd7a3bwf7mugupszik/lib/python3.8/multiprocessing/forkserver.py:84: in connect_to_new_process
        self.ensure_running()
            fds        = []
            self       = <multiprocessing.forkserver.ForkServer object at 0xffff7995fd60>
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    
    self = <multiprocessing.forkserver.ForkServer object at 0xffff7995fd60>
    
        def ensure_running(self):
            '''Make sure that a fork server is running.
    
            This can be called from any process.  Note that usually a child
            process will just reuse the forkserver started by its parent, so
            ensure_running() will do nothing.
            '''
            with self._lock:
                resource_tracker.ensure_running()
                if self._forkserver_pid is not None:
                    # forkserver was launched before, is it still running?
                    pid, status = os.waitpid(self._forkserver_pid, os.WNOHANG)
                    if not pid:
                        # still alive
                        return
                    # dead, launch it again
                    os.close(self._forkserver_alive_fd)
                    self._forkserver_address = None
                    self._forkserver_alive_fd = None
                    self._forkserver_pid = None
    
                cmd = ('from multiprocessing.forkserver import main; ' +
                       'main(%d, %d, %r, **%r)')
    
                if self._preload_modules:
                    desired_keys = {'main_path', 'sys_path'}
                    data = spawn.get_preparation_data('ignore')
                    data = {x: y for x, y in data.items() if x in desired_keys}
                else:
                    data = {}
    
                with socket.socket(socket.AF_UNIX) as listener:
                    address = connection.arbitrary_address('AF_UNIX')
    >               listener.bind(address)
    E               OSError: AF_UNIX path too long
    
    address    = '/home/stage/root/spack-stage-py-pybind11-master-buhdtf3eegctgi7bjpxzrr5rgfkal5y2/spack-src/.nox/tests-3-8/tmp/pymp-2y6zv958/listener-xwlet19c'
    cmd        = 'from multiprocessing.forkserver import main; main(%d, %d, %r, **%r)'
    data       = {'sys_path': ['/home/stage/root/spack-stage-py-pybind11-master-buhdtf3eegctgi7bjpxzrr5rgfkal5y2/spack-src/tests', '/ho.../spack/opt/spack/linux-centos8-aarch64/gcc-8.5.0/python-3.8.8-m3k3pvne56yo7wyd7a3bwf7mugupszik/lib/python38.zip', ...]}
    desired_keys = {'main_path', 'sys_path'}
    listener   = <socket.socket [closed] fd=-1, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0>
    self       = <multiprocessing.forkserver.ForkServer object at 0xffff7995fd60>
    
    /home/spack/opt/spack/linux-centos8-aarch64/gcc-8.5.0/python-3.8.8-m3k3pvne56yo7wyd7a3bwf7mugupszik/lib/python3.8/multiprocessing/forkserver.py:138: OSError
    ========================================================================================= short test summary info =========================================================================================
    SKIPPED [1] ../../../../tests/test_builtin_casters.py:145: no <string_view>
    SKIPPED [1] ../../../../tests/test_callbacks.py:203: Current PYBIND11_INTERNALS_VERSION too low
    SKIPPED [1] ../../../../tests/test_copy_move.py:77: no <optional>
    SKIPPED [1] ../../../../tests/test_sequences_and_iterators.py:13: no <optional>
    SKIPPED [1] ../../../../tests/test_stl.py:111: no <optional>
    SKIPPED [1] ../../../../tests/test_stl.py:143: no <experimental/optional>
    SKIPPED [1] ../../../../tests/test_stl.py:175: no <boost/optional>
    SKIPPED [1] ../../../../tests/test_stl.py:234: no <filesystem>
    SKIPPED [1] ../../../../tests/test_stl.py:253: no <variant>
    SKIPPED [1] ../../../../tests/test_stl.py:270: no std::monostate
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_one_thread[test_callback_py_obj] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_one_thread[test_callback_std_func] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_one_thread[test_callback_virtual_func] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_one_thread[test_callback_pure_virtual_func] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_one_thread[test_cross_module_gil_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_one_thread[test_cross_module_gil_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_one_thread[test_cross_module_gil_inner_custom_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_one_thread[test_cross_module_gil_inner_custom_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_one_thread[test_cross_module_gil_inner_pybind11_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_one_thread[test_cross_module_gil_inner_pybind11_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_one_thread[test_cross_module_gil_nested_custom_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_one_thread[test_cross_module_gil_nested_custom_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_one_thread[test_cross_module_gil_nested_pybind11_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_one_thread[test_cross_module_gil_nested_pybind11_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_one_thread[test_release_acquire] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_one_thread[test_nested_acquire] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_one_thread[test_multi_acquire_release_cross_module] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_one_thread[_intentional_deadlock] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_parallel[test_callback_py_obj] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_parallel[test_callback_std_func] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_parallel[test_callback_virtual_func] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_parallel[test_callback_pure_virtual_func] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_parallel[test_cross_module_gil_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_parallel[test_cross_module_gil_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_parallel[test_cross_module_gil_inner_custom_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_parallel[test_cross_module_gil_inner_custom_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_parallel[test_cross_module_gil_inner_pybind11_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_parallel[test_cross_module_gil_inner_pybind11_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_parallel[test_cross_module_gil_nested_custom_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_parallel[test_cross_module_gil_nested_custom_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_parallel[test_cross_module_gil_nested_pybind11_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_parallel[test_cross_module_gil_nested_pybind11_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_parallel[test_release_acquire] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_parallel[test_nested_acquire] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_parallel[test_multi_acquire_release_cross_module] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_parallel[_intentional_deadlock] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_callback_py_obj] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_callback_std_func] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_callback_virtual_func] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_callback_pure_virtual_func] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_cross_module_gil_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_cross_module_gil_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_cross_module_gil_inner_custom_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_cross_module_gil_inner_custom_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_cross_module_gil_inner_pybind11_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_cross_module_gil_inner_pybind11_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_cross_module_gil_nested_custom_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_cross_module_gil_nested_custom_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_cross_module_gil_nested_pybind11_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_cross_module_gil_nested_pybind11_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_release_acquire] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_nested_acquire] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_multi_acquire_release_cross_module] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[_intentional_deadlock] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_direct[test_callback_py_obj] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_direct[test_callback_std_func] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_direct[test_callback_virtual_func] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_direct[test_callback_pure_virtual_func] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_direct[test_cross_module_gil_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_direct[test_cross_module_gil_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_direct[test_cross_module_gil_inner_custom_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_direct[test_cross_module_gil_inner_custom_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_direct[test_cross_module_gil_inner_pybind11_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_direct[test_cross_module_gil_inner_pybind11_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_direct[test_cross_module_gil_nested_custom_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_direct[test_cross_module_gil_nested_custom_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_direct[test_cross_module_gil_nested_pybind11_released] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_direct[test_cross_module_gil_nested_pybind11_acquired] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_direct[test_release_acquire] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_direct[test_nested_acquire] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_direct[test_multi_acquire_release_cross_module] - OSError: AF_UNIX path too long
    FAILED ../../../../tests/test_gil_scoped.py::test_run_in_process_direct[_intentional_deadlock] - OSError: AF_UNIX path too long
    =============================================================================== 72 failed, 711 passed, 10 skipped in 28.18s ===============================================================================
    gmake[3]: *** [tests/CMakeFiles/pytest.dir/build.make:74: tests/CMakeFiles/pytest] Error 1
    gmake[2]: *** [CMakeFiles/Makefile2:385: tests/CMakeFiles/pytest.dir/all] Error 2
    gmake[1]: *** [CMakeFiles/Makefile2:450: tests/CMakeFiles/check.dir/rule] Error 2
    gmake: *** [Makefile:274: check] Error 2
    nox > Command cmake --build .nox/tests-3-8/tmp --config=Release --target check failed with exit code 2
    nox > Session tests-3.8 failed.
    nox > Running session tests-3.9
    nox > Missing interpreters will error by default on CI systems.
    nox > Session tests-3.9 skipped: Python interpreter 3.9 not found.
    nox > Running session tests-3.10
    nox > Missing interpreters will error by default on CI systems.
    nox > Session tests-3.10 skipped: Python interpreter 3.10 not found.
    nox > Running session tests-3.11
    nox > Missing interpreters will error by default on CI systems.
    nox > Session tests-3.11 skipped: Python interpreter 3.11 not found.
    nox > Running session tests-pypy3.7
    nox > Missing interpreters will error by default on CI systems.
    nox > Session tests-pypy3.7 skipped: Python interpreter pypy3.7 not found.
    nox > Running session tests-pypy3.8
    nox > Missing interpreters will error by default on CI systems.
    nox > Session tests-pypy3.8 skipped: Python interpreter pypy3.8 not found.
    nox > Running session tests-pypy3.9
    nox > Missing interpreters will error by default on CI systems.
    nox > Session tests-pypy3.9 skipped: Python interpreter pypy3.9 not found.
    nox > Ran multiple sessions:
    nox > * tests-3.8: failed
    nox > * tests-3.9: skipped
    nox > * tests-3.10: skipped
    nox > * tests-3.11: skipped
    nox > * tests-pypy3.7: skipped
    nox > * tests-pypy3.8: skipped
    nox > * tests-pypy3.9: skipped
    

    Reproducible example code

    No response

    Is this a regression? Put the last known working version here if it is.

    Not a regression

    triage 
    opened by Tom-python0121 0
  • DEBUG (not for merging): issue 4420 reproducer

    DEBUG (not for merging): issue 4420 reproducer

    The development team requested (https://github.com/scipy/scipy/issues/17644#issuecomment-1365537213) a reproducer in the CI for gh-4420.

    • first commit cuts down the CI to prevent wasting
    • second commit formalizes some of my reproducing instructions so you can see the failure with the latest release of pybind11 in CI (if you switch down to the 2.10.1 release there you should see the job pass)
    • I realise you might prefer to build master from source to debug rather than me pip installing the latest stable release in the repo proper, but obviously this team should be able to alter this workflow to do that if desired..
    opened by tylerjereddy 2
  • [BUG]: module hangs on init

    [BUG]: module hangs on init

    Required prerequisites

    What version (or hash if on master) of pybind11 are you using?

    2.10.0 (vcpkg)

    Problem description

    I'm producing a module that uses the date library On c++ initialization (aka on import my_module) the module (and python) hangs since the library is trying to access some data using curl. Windows is blocked in "waitforsingleobject" and linux in "__GI___select", same behaviour. If I disable the auto-check of tzdata the module works normally.

    Anuy idea why python/pybind11 interacts badly with curl on init ?

    Reproducible example code

    I can submit a minimal example if needed.
    

    Is this a regression? Put the last known working version here if it is.

    Not a regression

    triage 
    opened by reder2000 0
  • [BUG]: Pass by reference does copy

    [BUG]: Pass by reference does copy

    Required prerequisites

    What version (or hash if on master) of pybind11 are you using?

    2.10.2

    Problem description

    The docs state that passing arguments as reference and pointer should work, but actually, while pointers works well, references dont. They end up beeing copied, which is a blocker if the type is not copy constructible.

    class PyPlugin
    {
    public:
        virtual void takeThisAndModifyR(StandardItem &item) {};
        virtual void takeThisAndModifyP(StandardItem *item) {};
    };
    class PyPluginTrampoline : PyPlugin
    {
    public:
        using PyPlugin::PyPlugin;  // Inherit the constructors
        void takeThisAndModifyR(StandardItem &item) override  { PYBIND11_OVERRIDE(void, PyPlugin, takeThisAndModifyR, item); }
        void takeThisAndModifyP(StandardItem *item) override { PYBIND11_OVERRIDE(void, PyPlugin, takeThisAndModifyP, item); }
    };
    
    

    Then in a pyhton plugin I do:

    
    class Plugin(Plugin):
      …
        def takeThisAndModifyR(self, item):
            item.id = "takeThisAndModifyR";
    
        def takeThisAndModifyP(self, item):
            item.id = "takeThisAndModifyP";
    …
    
    

    In the app i do

    auto item = StandardItem("id");
    INFO << item.id();
    p->takeThisAndModifyP(&item);
    INFO << item.id();
    p->takeThisAndModifyR(item);
    INFO << item.id();
    

    Finally this prints:

    10:47:43 [info:python] id
    10:47:43 [info:python] takeThisAndModifyP
    10:47:43 [warn:albert] [17ms] Failed loading 'find': return_value_policy = copy, but type albert::StandardItem is non-copyable!
    

    Of course I exposed the item class. Left it out for readability. Obviously pybind does not like references. Is this a bug or a known limitation and I should rather look for a workaround?

    Related:

    • https://github.com/pybind/pybind11/discussions/3991
    • https://stackoverflow.com/questions/72500615/how-to-pass-arguments-by-reference-when-call-python-in-c-with-pybind11
    • https://pybind11.readthedocs.io/en/stable/faq.html#limitations-involving-reference-arguments
    • https://github.com/pybind/pybind11/issues/1123

    Reproducible example code

    No response

    Is this a regression? Put the last known working version here if it is.

    Not a regression

    triage 
    opened by ManuelSchneid3r 0
  • [BUG]: Test test_run_in_process_multiple_threads_sequential fails

    [BUG]: Test test_run_in_process_multiple_threads_sequential fails

    Required prerequisites

    What version (or hash if on master) of pybind11 are you using?

    2.10.2

    Problem description

    __________________________________________________ test_run_in_process_multiple_threads_sequential[test_multi_acquire_release_cross_module] __________________________________________________
    
    test_fn = <function test_multi_acquire_release_cross_module at 0x8cbf75280>
    
        @pytest.mark.parametrize("test_fn", ALL_BASIC_TESTS_PLUS_INTENTIONAL_DEADLOCK)
        def test_run_in_process_multiple_threads_sequential(test_fn):
            """Makes sure there is no GIL deadlock when running in a thread multiple times sequentially.
        
            It runs in a separate process to be able to stop and assert if it deadlocks.
            """
    >       assert _run_in_process(_run_in_threads, test_fn, num_threads=8, parallel=False) == 0
    
    test_fn    = <function test_multi_acquire_release_cross_module at 0x8cbf75280>
    
    ../../pybind11-2.10.2/tests/test_gil_scoped.py:234: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    target = <function _run_in_threads at 0x8cbf754c0>, args = (<function test_multi_acquire_release_cross_module at 0x8cbf75280>,), kwargs = {'num_threads': 8, 'parallel': False}
    test_fn = <function test_multi_acquire_release_cross_module at 0x8cbf75280>, timeout = 10, process = <Process name='Process-53' pid=32667 parent=30786 stopped exitcode=-SIGTERM daemon>
    t_start = 1671766594.3010159, t_delta = 10.004453420639038, @py_assert1 = None
    
        def _run_in_process(target, *args, **kwargs):
            if len(args) == 0:
                test_fn = target
            else:
                test_fn = args[0]
            # Do not need to wait much, 10s should be more than enough.
            timeout = 0.1 if test_fn is _intentional_deadlock else 10
            process = multiprocessing.Process(target=target, args=args, kwargs=kwargs)
            process.daemon = True
            try:
                t_start = time.time()
                process.start()
                if timeout >= 100:  # For debugging.
                    print(
                        "\nprocess.pid STARTED", process.pid, (sys.argv, target, args, kwargs)
                    )
                    print(f"COPY-PASTE-THIS: gdb {sys.argv[0]} -p {process.pid}", flush=True)
                process.join(timeout=timeout)
                if timeout >= 100:
                    print("\nprocess.pid JOINED", process.pid, flush=True)
                t_delta = time.time() - t_start
                if process.exitcode == 66 and m.defined_THREAD_SANITIZER:  # Issue #2754
                    # WOULD-BE-NICE-TO-HAVE: Check that the message below is actually in the output.
                    # Maybe this could work:
                    # https://gist.github.com/alexeygrigorev/01ce847f2e721b513b42ea4a6c96905e
                    pytest.skip(
                        "ThreadSanitizer: starting new threads after multi-threaded fork is not supported."
                    )
                elif test_fn is _intentional_deadlock:
                    assert process.exitcode is None
                    return 0
                elif process.exitcode is None:
                    assert t_delta > 0.9 * timeout
                    msg = "DEADLOCK, most likely, exactly what this test is meant to detect."
                    if env.PYPY and env.WIN:
                        pytest.skip(msg)
    >               raise RuntimeError(msg)
    E               RuntimeError: DEADLOCK, most likely, exactly what this test is meant to detect.
    
    args       = (<function test_multi_acquire_release_cross_module at 0x8cbf75280>,)
    kwargs     = {'num_threads': 8, 'parallel': False}
    msg        = 'DEADLOCK, most likely, exactly what this test is meant to detect.'
    process    = <Process name='Process-53' pid=32667 parent=30786 stopped exitcode=-SIGTERM daemon>
    t_delta    = 10.004453420639038
    t_start    = 1671766594.3010159
    target     = <function _run_in_threads at 0x8cbf754c0>
    test_fn    = <function test_multi_acquire_release_cross_module at 0x8cbf75280>
    timeout    = 10
    
    ../../pybind11-2.10.2/tests/test_gil_scoped.py:186: RuntimeError
    ================================================================================== short test summary info ===================================================================================
    SKIPPED [1] ../../pybind11-2.10.2/tests/test_builtin_casters.py:145: no <string_view>
    SKIPPED [1] ../../pybind11-2.10.2/tests/test_callbacks.py:203: Current PYBIND11_INTERNALS_VERSION too low
    SKIPPED [1] ../../pybind11-2.10.2/tests/test_copy_move.py:77: no <optional>
    SKIPPED [1] ../../pybind11-2.10.2/tests/test_pytypes.py:397: Not defined: PYBIND11_HANDLE_REF_DEBUG
    SKIPPED [1] ../../pybind11-2.10.2/tests/test_sequences_and_iterators.py:13: no <optional>
    SKIPPED [1] ../../pybind11-2.10.2/tests/test_stl.py:111: no <optional>
    SKIPPED [1] ../../pybind11-2.10.2/tests/test_stl.py:143: no <experimental/optional>
    SKIPPED [1] ../../pybind11-2.10.2/tests/test_stl.py:234: no <filesystem>
    SKIPPED [1] ../../pybind11-2.10.2/tests/test_stl.py:270: no std::monostate
    FAILED ../../pybind11-2.10.2/tests/test_exceptions.py::test_cross_module_exception_translator - RuntimeError
    FAILED ../../pybind11-2.10.2/tests/test_gil_scoped.py::test_run_in_process_multiple_threads_sequential[test_multi_acquire_release_cross_module] - RuntimeError: DEADLOCK, most likely, exactly what this test is meant to detect.
    ==================================================================== 2 failed, 780 passed, 9 skipped in 151.14s (0:02:31) ====================================================================
    

    Reproducible example code

    No response

    Is this a regression? Put the last known working version here if it is.

    Not a regression

    triage 
    opened by yurivict 0
Releases(v2.10.3)
  • v2.10.3(Jan 3, 2023)

    Changes:

    • Temporarily made our GIL status assertions (added in 2.10.2) disabled by default (re-enable manually by defining PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF, will be enabled in 2.11). #4432
    • Improved error messages when inc_ref/dec_ref are called with an invalid GIL state. #4427 #4436

    Bug Fixes:

    • Some minor touchups found by static analyzers. #4440
    Source code(tar.gz)
    Source code(zip)
  • v2.10.2(Dec 20, 2022)

    Changes:

    • scoped_interpreter constructor taking PyConfig. #4372
    • pybind11/eigen/tensor.h adds converters to and from Eigen::Tensor and Eigen::TensorMap #4201
    • PyGILState_Check()'s were integrated to pybind11::handle inc_ref() & dec_ref(). The added GIL checks are guarded by PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF, which is the default only if NDEBUG is not defined. #4246
    • Add option for enable/disable enum members in docstring. #2768
    • Fixed typing of KeysView, ValuesView and ItemsView in bind_map. #4353

    Bug fixes:

    • Bug fix affecting only Python 3.6 under very specific, uncommon conditions: move PyEval_InitThreads() call to the correct location. #4350
    • Fix segfault bug when passing foreign native functions to functional.h. #4254

    Build system improvements:

    • Support setting PYTHON_LIBRARIES manually for Windows ARM cross-compilation (classic mode). #4406
    • Extend IPO/LTO detection for ICX (a.k.a IntelLLVM) compiler. #4402
    • Allow calling find_package(pybind11 CONFIG) multiple times from separate directories in the same CMake project and properly link Python (new mode). #4401
    • multiprocessing_set_spawn in pytest fixture for added safety. #4377
    • Fixed a bug in two pybind11/tools cmake scripts causing "Unknown arguments specified" errors. #4327
    Source code(tar.gz)
    Source code(zip)
  • v2.10.1(Oct 31, 2022)

    This is the first version to fully support embedding the newly released Python 3.11.

    Changes:

    • Allow pybind11::capsule constructor to take null destructor pointers. #4221
    • embed.h was changed so that PYTHONPATH is used also with Python 3.11 (established behavior). #4119
    • A PYBIND11_SIMPLE_GIL_MANAGEMENT option was added (cmake, C++ define), along with many additional tests in test_gil_scoped.py. The option may be useful to try when debugging GIL-related issues, to determine if the more complex default implementation is or is not to blame. See #4216 for background. WARNING: Please be careful to not create ODR violations when using the option: everything that is linked together with mutual symbol visibility needs to be rebuilt. #4216
    • PYBIND11_EXPORT_EXCEPTION was made non-empty only under macOS. This makes Linux builds safer, and enables the removal of warning suppression pragmas for Windows. #4298

    Bug fixes:

    • Fixed a bug where UnicodeDecodeError was not propagated from various py::str ctors when decoding surrogate utf characters. #4294
    • Revert perfect forwarding for make_iterator. This broke at least one valid use case. May revisit later. #4234
    • Fix support for safe casts to void* (regression in 2.10.0). #4275
    • Fix char8_t support (regression in 2.9). #4278
    • Unicode surrogate character in Python exception message leads to process termination in error_already_set::what(). #4297
    • Fix MSVC 2019 v.1924 & C++14 mode error for overload_cast. #4188
    • Make augmented assignment operators non-const for the object-api. Behavior was previously broken for augmented assignment operators. #4065
    • Add proper error checking to C++ bindings for Python list append and insert. #4208
    • Work-around for Nvidia's CUDA nvcc compiler in versions 11.4.0 - 11.8.0. #4220
    • A workaround for PyPy was added in the py::error_already_set implementation, related to PR #1895 released with v2.10.0. #4079
    • Fixed compiler errors when C++23 std::forward_like is available. #4136
    • Properly raise exceptions in contains methods (like when an object in unhashable). #4209
    • Further improve another error in exception handling. #4232
    • get_local_internals() was made compatible with finalize_interpreter(), fixing potential freezes during interpreter finalization. #4192

    Performance and style:

    • Reserve space in set and STL map casters if possible. This will prevent unnecessary rehashing / resizing by knowing the number of keys ahead of time for Python to C++ casting. This improvement will greatly speed up the casting of large unordered maps and sets. #4194
    • GIL RAII scopes are non-copyable to avoid potential bugs. #4183
    • Explicitly default all relevant ctors for pytypes in the PYBIND11_OBJECT macros and enforce the clang-tidy checks modernize-use-equals-default in macros as well. #4017
    • Optimize iterator advancement in C++ bindings. #4237
    • Use the modern PyObject_GenericGetDict and PyObject_GenericSetDict for handling dynamic attribute dictionaries. #4106
    • Document that users should use PYBIND11_NAMESPACE instead of using pybind11 when opening namespaces. Using namespace declarations and namespace qualification remain the same as pybind11. This is done to ensure consistent symbol visibility. #4098
    • Mark detail::forward_like as constexpr. #4147
    • Optimize unpacking_collector when processing arg_v arguments. #4219
    • Optimize casting C++ object to None. #4269

    Build system improvements:

    • CMake: revert overwrite behavior, now opt-in with PYBIND11_PYTHONLIBS_OVERRWRITE OFF. #4195
    • Include a pkg-config file when installing pybind11, such as in the Python package. #4077
    • Avoid stripping debug symbols when CMAKE_BUILD_TYPE is set to DEBUG instead of Debug. #4078
    • Followup to #3948, fixing vcpkg again. #4123
    Source code(tar.gz)
    Source code(zip)
  • v2.10.0(Jul 16, 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
    • Support bytearray casting to string. #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
    • pybind11::capsule::set_name added to mutate the name of the capsule instance. #3866
    • NumPy: dtype constructor from type number added, accessors corresponding to Python API dtype.num, dtype.byteorder, dtype.flags and dtype.alignment added. #3868

    Changes:

    • Python 3.6 is now the minimum supported version. #3688 #3719
    • The minimum version for MSVC is now 2017. #3722
    • Fix issues with CPython 3.11 betas and add to supported test matrix. #3923
    • error_already_set is now safer and more performant, especially for exceptions with long tracebacks, by delaying computation. #1895
    • Improve exception handling in python str bindings. #3826
    • The bindings for capsules now have more consistent exception handling. #3825
    • PYBIND11_OBJECT_CVT and PYBIND11_OBJECT_CVT_DEFAULT macro can now be used to define classes in namespaces other than pybind11. #3797
    • Error printing code now uses PYBIND11_DETAILED_ERROR_MESSAGES instead of requiring NDEBUG, allowing use with release builds if desired. #3913
    • Implicit conversion of the literal 0 to pybind11::handle is now disabled. #4008

    Bug fixes:

    • Fix exception handling when pybind11::weakref() fails. #3739
    • module_::def_submodule was missing proper error handling. This is fixed now. #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
    • error_already_set::what() now handles non-normalized exceptions correctly. #3971
    • Support older C++ compilers where filesystem is not yet part of the standard library and is instead included in std::experimental::filesystem. #3840
    • Fix -Wfree-nonheap-object warnings produced by GCC by avoiding returning pointers to static objects with return_value_policy::take_ownership. #3946
    • Fix cast from pytype rvalue to another pytype. #3949
    • Ensure proper behavior when garbage collecting classes with dynamic attributes in Python >=3.9. #4051
    • A couple long-standing PYBIND11_NAMESPACE __attribute__((visibility("hidden"))) inconsistencies are now fixed (affects only unusual environments). #4043
    • pybind11::detail::get_internals() is now resilient to in-flight Python exceptions. #3981
    • Arrays with a dimension of size 0 are now properly converted to dynamic Eigen matrices (more common in NumPy 1.23). #4038
    • Avoid catching unrelated errors when importing NumPy. #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
    • Perfect forward all args of make_iterator. #3980
    • Avoid potential bug in pycapsule destructor by adding an error_guard to one of the dtors. #3958
    • Optimize dictionary access in strip_padding for numpy. #3994
    • stl_bind.h bindings now take slice args as a const-ref. #3852
    • Made slice constructor more consistent, and improve performance of some casters by allowing reference stealing. #3845
    • Change numpy dtype from_args method to use const ref. #3878
    • Follow rule of three to ensure PyErr_Restore is called only once. #3872
    • Added missing perfect forwarding for make_iterator functions. #3860
    • Optimize c++ to python function casting by using the rvalue caster. #3966
    • Optimize Eigen sparse matrix casting by removing unnecessary temporary. #4064
    • Avoid potential implicit copy/assignment constructors causing double free in strdup_gaurd. #3905
    • Enable clang-tidy checks misc-definitions-in-headers, modernize-loop-convert, and modernize-use-nullptr. #3881 #3988

    Build system improvements:

    • CMake: Fix file extension on Windows with cp36 and cp37 using FindPython. #3919
    • CMake: Support multiple Python targets (such as on vcpkg). #3948
    • CMake: Fix issue with NVCC on Windows. #3947
    • CMake: Drop the bitness check on cross compiles (like targeting WebAssembly via Emscripten). #3959
    • Add MSVC builds in debug mode to CI. #3784
    • MSVC 2022 C++20 coverage was added to GitHub Actions, including Eigen. #3732, #3741

    Backend and tidying up:

    • New theme for the documentation. #3109
    • Remove idioms in code comments. Use more inclusive language. #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
    • Avoid setup.py <command> usage in internal tests. #3734
    Source code(tar.gz)
    Source code(zip)
  • v2.9.2(Mar 31, 2022)

    Changes:

    • Enum now has an __index__ method on Python <3.8 too. #3700
    • Local internals are now cleared after finalizing the interpreter. #3744

    Bug fixes:

    • Better support for Python 3.11 alphas. #3694
    • PYBIND11_TYPE_CASTER now uses fully qualified symbols, so it can be used outside of pybind11::detail. #3758
    • Some fixes for PyPy 3.9. #3768
    • Fixed a potential memleak in PyPy in get_type_override. #3774
    • Fix usage of VISIBILITY_INLINES_HIDDEN. #3721

    Build system improvements:

    • Uses sysconfig module to determine installation locations on Python >= 3.10, instead of distutils which has been deprecated. #3764
    • Support Catch 2.13.5+ (supporting GLIBC 2.34+). #3679
    • Fix test failures with numpy 1.22 by ignoring whitespace when comparing str() of dtypes. #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, #3699, #3716, #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
    Source code(tar.gz)
    Source code(zip)
  • v2.9.1(Feb 3, 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
    • 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
    • Propagate Python exception traceback using raise_from if a pybind11 function runs out of overloads. #3671
    • py::multiple_inheritance is now only needed when C++ bases are hidden from pybind11. #3650 and #3659

    Bug fixes:

    • Remove a boolean cast in numpy.h that causes MSVC C4800 warnings when compiling against Python 3.10 or newer. #3669
    • Render py::bool_ and py::float_ as bool and float respectively. #3622

    Build system improvements:

    • Fix CMake extension suffix computation on Python 3.10+. #3663
    • Allow CMAKE_ARGS to override CMake args in pybind11's own setup.py. #3577
    • Remove a few deprecated c-headers. #3610
    • More uniform handling of test targets. #3590
    • Add clang-tidy readability check to catch potentially swapped function args. #3611
    Source code(tar.gz)
    Source code(zip)
  • v2.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

    Changes:

    • Make str/bytes/memoryview more interoperable with std::string_view. #3521
    • Replace _ with const_name in internals, avoid defining pybind::_ if _ defined as macro (common gettext usage) #3423

    Bug fixes:

    • Fix a rare warning about extra copy in an Eigen constructor. #3486
    • Fix caching of the C++ overrides. #3465
    • Add missing std::forward calls to some cpp_function overloads. #3443
    • Support PyPy 7.3.7 and the PyPy3.8 beta. Test python-3.11 on PRs with the python dev label. #3419
    • Replace usage of deprecated Eigen::MappedSparseMatrix with Eigen::Map<Eigen::SparseMatrix<...>> for Eigen 3.3+. #3499
    • Tweaks to support Microsoft Visual Studio 2022. #3497

    Build system improvements:

    • Nicer CMake printout and IDE organisation for pybind11's own tests. #3479
    • CMake: report version type as part of the version string to avoid a spurious space in the package status message. #3472
    • Flags starting with -g in $CFLAGS and $CPPFLAGS are no longer overridden by .Pybind11Extension. #3436
    • Ensure ThreadPool is closed in setup_helpers. #3548
    • Avoid LTS on mips64 and ppc64le (reported broken). #3557
    Source code(tar.gz)
    Source code(zip)
  • v2.8.1(Oct 27, 2021)

    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
    • Add C++ Exception type to throw and catch AttributeError. Useful for defining custom __setattr__ and __getattr__ methods. #3387

    Fixes:

    • Fixed the potential for dangling references when using properties with std::optional types. #3376
    • Modernize usage of PyCodeObject on Python 3.9+ (moving toward support for Python 3.11a1) #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
    • Support multiple raw inclusion of CMake helper files (Conan.io does this for multi-config generators). #3420
    • Fix harmless warning on upcoming CMake 3.22. #3368
    • Fix 2.8.0 regression with MSVC 2017 + C++17 mode + Python 3. #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
    Source code(tar.gz)
    Source code(zip)
  • v2.8.0(Oct 4, 2021)

    New features:

    • Added py::raise_from to enable chaining exceptions. #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
    • Add make_simple_namespace function for instantiating Python SimpleNamespace objects. #2840
    • pybind11::scoped_interpreter and initialize_interpreter have new arguments to allow sys.argv initialization. #2341
    • Allow Python builtins to be used as callbacks in CPython. #1413
    • Added view to view arrays with a different datatype. #987
    • Implemented reshape on arrays. #984
    • Enable defining custom __new__ methods on classes by fixing bug preventing overriding methods if they have non-pybind11 siblings. #3265
    • Add make_value_iterator(), and fix make_key_iterator() to return references instead of copies. #3293
    • Improve the classes generated by bind_map: #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

    Changes:

    • Set __file__ constant when running eval_file in an embedded interpreter. #3233
    • Python objects and (C++17) std::optional now accepted in py::slice constructor. #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
    • Avoid evaluating PYBIND11_TLS_REPLACE_VALUE arguments more than once. #3290

    Fixes:

    • Bug fix: enum value's __int__ returning non-int when underlying type is bool or of char type #1334
    • Fixes bug in setting error state in Capsule's pointer methods. #3261
    • A long-standing memory leak in py::cpp_function::initialize was fixed. #3229
    • Fixes thread safety for some pybind11::type_caster which require lifetime extension, such as for std::string_view. #3237
    • Restore compatibility with gcc 4.8.4 as distributed by ubuntu-trusty, linuxmint-17. #3270

    Build system improvements:

    • Fix regression in CMake Python package config: improper use of absolute path. #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
    • Specified UTF8-encoding in setup.py calls of open(). #3137
    • Fix a harmless warning from CMake 3.21 with the classic Python discovery. #3220
    • Eigen repo and version can now be specified as cmake options. #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
    • Optimize NumPy array construction with additional moves. #3183
    • Conversion to std::string and std::string_view now avoids making an extra copy of the data on Python >= 3.3. #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 #3194
    • The clang-tidy google-explicit-constructor option was enabled. #3250
    • Mark a pytype move constructor as noexcept (perf). #3236
    • Enable clang-tidy check to guard against inheritance slicing. #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
    • Format pybind11 with isort consistent ordering of imports #3195
    • The warnings-suppression "pragma clamp" at the top/bottom of pybind11 was removed, clearing the path to refactoring and IWYU cleanup. #3186
    • Enable most bugprone checks in clang-tidy and fix the found potential bugs and poor coding styles. #3166
    • Add clang-tidy-readability rules to make boolean casts explicit improving code readability. Also enabled other misc and readability clang-tidy checks. #3148
    • Move object in .pop() for list. #3116
    Source code(tar.gz)
    Source code(zip)
  • v2.7.1(Aug 3, 2021)

    Minor missing functionality added:

    • Allow Python builtins to be used as callbacks in CPython. #1413

    Bug fixes:

    • Fix regression in CMake Python package config: improper use of absolute path. #3144
    • Fix Mingw64 and add to the CI testing matrix. #3132
    • Specified UTF8-encoding in setup.py calls of open(). #3137
    • Add clang-tidy-readability rules to make boolean casts explicit improving code readability. Also enabled other misc and readability clang-tidy checks. #3148
    • Move object in .pop() for list. #3116

    Backend and tidying up:

    Source code(tar.gz)
    Source code(zip)
  • v2.7.0(Jul 16, 2021)

    New features:

    • Enable py::implicitly_convertible<py::none, ...> for py::class_-wrapped types. #3059
    • Allow function pointer extraction from overloaded functions. #2944
    • NumPy: added .char_() to type which gives the NumPy public char result, which also distinguishes types by bit length (unlike .kind()). #2864
    • Add pybind11::bytearray to manipulate bytearray similar to bytes. #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
    • A PYBIND11_VERSION_HEX define was added, similar to PY_VERSION_HEX. #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
    • 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
    • Catch a missing self argument in calls to __init__(). #2914
    • Use std::string_view if available to avoid a copy when passing an object to a std::ostream. #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

    Fixes:

    • Performance: avoid unnecessary strlen calls. #3058
    • Fix auto-generated documentation string when using const T in pyarray_t. #3020
    • Unify error messages thrown by simple_collector/unpacking_collector. #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
    • Fixed exception when printing UTF-8 to a scoped_ostream_redirect. #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
    • Allow negative timedelta values to roundtrip. #2870
    • Fix unchecked errors could potentially swallow signals/other exceptions. #2863
    • Add null pointer check with std::localtime. #2846
    • Fix the weakref constructor from py::object to create a new weakref on conversion. #2832
    • Avoid relying on exceptions in C++17 when getting a shared_ptr holder from a shared_from_this class. #2819
    • Allow the codec's exception to be raised instead of RuntimeError when casting from py::str to std::string. #2903

    Build system improvements:

    • In setup_helpers.py, test for platforms that have some multiprocessing features but lack semaphores, which ParallelCompile requires. #3043
    • Fix pybind11_INCLUDE_DIR in case CMAKE_INSTALL_INCLUDEDIR is absolute. #3005
    • Fix bug not respecting WITH_SOABI or WITHOUT_SOABI to CMake. #2938
    • Fix the default Pybind11Extension compilation flags with a Mingw64 python. #2921
    • Clang on Windows: do not pass /MP (ignored flag). #2824
    • pybind11.setup_helpers.intree_extensions can be used to generate Pybind11Extension instances from cpp files placed in the Python package source tree. #2831

    Backend and tidying up:

    • Enable clang-tidy performance, readability, and modernization checks throughout the codebase to enforce best coding practices. #3046, #3049, #3051, #3052, #3080, and #3094
    • Checks for common misspellings were added to the pre-commit hooks. #3076
    • Changed Werror to stricter Werror-all for Intel compiler and fixed minor issues. #2948
    • Fixed compilation with GCC < 5 when the user defines _GLIBCXX_USE_CXX11_ABI. #2956
    • Added nox support for easier local testing and linting of contributions. #3101 and #3121
    • Avoid RTD style issue with docutils 0.17+. #3119
    • Support pipx run, such as pipx run pybind11 --include for a quick compile. #3117
    Source code(tar.gz)
    Source code(zip)
  • v2.6.2(Jan 27, 2021)

    Minor missing functionality added:

    • enum: add missing Enum.value property. #2739
    • Allow thread termination to be avoided during shutdown for CPython 3.7+ via .disarm for gil_scoped_acquire/gil_scoped_release. #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
    • The type_caster for integers does not convert Python objects with __int__ anymore with noconvert or during the first round of trying overloads. #2698
    • When casting to a C++ integer, __index__ is always called and not considered as conversion, consistent with Python 3.8+. #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
    • Setup helpers: Don't trigger unused parameter warning. #2735
    • CMake: Support running with --warn-uninitialized active. #2806
    • CMake: Avoid error if included from two submodule directories. #2804
    • CMake: Fix STATIC / SHARED being ignored in FindPython mode. #2796
    • CMake: Respect the setting for CMAKE_CXX_VISIBILITY_PRESET if defined. #2793
    • CMake: Fix issue with FindPython2/FindPython3 not working with pybind11::embed. #2662
    • CMake: mixing local and installed pybind11's would prioritize the installed one over the local one (regression in 2.6.0). #2716

    Bug fixes:

    • Fixed segfault in multithreaded environments when using scoped_ostream_redirect. #2675
    • Leave docstring unset when all docstring-related options are disabled, rather than set an empty string. #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
    • Fixed assertion error related to unhandled (later overwritten) exception in CPython 3.8 and 3.9 debug builds. #2685
    • Fix py::gil_scoped_acquire assert with CPython 3.9 debug build. #2683
    • Fix issue with a test failing on PyTest 6.2. #2741

    Warning fixes:

    • Fix warning modifying constructor parameter 'flag' that shadows a field of 'set_flag' [-Wshadow-field-in-constructor-modified]. #2780
    • Suppressed some deprecation warnings about old-style __init__/__setstate__ in the tests. #2759

    Valgrind work:

    • Fix invalid access when calling a pybind11 __init__ on a non-pybind11 class instance. #2755
    • Fixed various minor memory leaks in pybind11's test suite. #2758
    • Resolved memory leak in cpp_function initialization when exceptions occurred. #2756
    • Added a Valgrind build, checking for leaks and memory-related UB, to CI. #2746

    Compiler support:

    • Intel compiler was not activating C++14 support due to a broken define. #2679
    • Support ICC and NVIDIA HPC SDK in C++17 mode. #2729
    • Support Intel OneAPI compiler (ICC 20.2) and add to CI. #2573
    Source code(tar.gz)
    Source code(zip)
  • v2.6.1(Nov 12, 2020)

    • py::exec, py::eval, and py::eval_file now add the builtins module as "__builtins__" to their globals argument, better matching exec and eval in pure Python. #2616
    • setup_helpers will no longer set a minimum macOS version higher than the current version. #2622
    • Allow deleting static properties. #2629
    • Seal a leak in def_buffer, cleaning up the capture object after the class_ object goes out of scope. #2634
    • pybind11_INCLUDE_DIRS was incorrect, potentially causing a regression if it was expected to include PYTHON_INCLUDE_DIRS (please use targets instead). #2636
    • Added parameter names to the py::enum_ constructor and methods, avoiding arg0 in the generated docstrings. #2637
    • Added needs_recompile optional function to the ParallelCompiler helper, to allow a recompile to be skipped based on a user-defined function. #2643
    Source code(tar.gz)
    Source code(zip)
  • v2.6.0(Oct 21, 2020)

    New features:

    • Keyword-only arguments supported in Python 2 or 3 with py::kw_only(). #2100
    • Positional-only arguments supported in Python 2 or 3 with py::pos_only(). #2459
    • py::is_final() class modifier to block subclassing (CPython only). #2151
    • Added py::prepend(), allowing a function to be placed at the beginning of the overload chain. #1131
    • Access to the type object now provided with py::type::of<T>() and py::type::of(h). #2364
    • Perfect forwarding support for methods. #2048
    • Added py::error_already_set::discard_as_unraisable(). #2372
    • py::hash is now public. #2217
    • py::class_<union_type> is now supported. Note that writing to one data member of the union and reading another (type punning) is UB in C++. Thus pybind11-bound enums should never be used for such conversions. #2320.
    • Classes now check local scope when registering members, allowing a subclass to have a member with the same name as a parent (such as an enum). #2335

    Code correctness features:

    • Error now thrown when __init__ is forgotten on subclasses. #2152
    • Throw error if conversion to a pybind11 type if the Python object isn't a valid instance of that type, such as py::bytes(o) when py::object o isn't a bytes instance. #2349
    • Throw if conversion to str fails. #2477

    API changes:

    • py::module was renamed py::module_ to avoid issues with C++20 when used unqualified, but an alias py::module is provided for backward compatibility. #2489
    • Public constructors for py::module_ have been deprecated; please use pybind11::module_::create_extension_module if you were using the public constructor (fairly rare after PYBIND11_MODULE was introduced). #2552
    • PYBIND11_OVERLOAD* macros and get_overload function replaced by correctly-named PYBIND11_OVERRIDE* and get_override, fixing inconsistencies in the presence of a closing ; in these macros. get_type_overload is deprecated. #2325

    Packaging / building improvements:

    • The Python package was reworked to be more powerful and useful. #2433
      • build-setuptools is easier thanks to a new pybind11.setup_helpers module, which provides utilities to use setuptools with pybind11. It can be used via PEP 518, setup_requires, or by directly importing or copying setup_helpers.py into your project.
      • CMake configuration files are now included in the Python package. Use pybind11.get_cmake_dir() or python -m pybind11 --cmakedir to get the directory with the CMake configuration files, or include the site-packages location in your CMAKE_MODULE_PATH. Or you can use the new pybind11[global] extra when you install pybind11, which installs the CMake files and headers into your base environment in the standard location.
      • pybind11-config is another way to write python -m pybind11 if you have your PATH set up.
      • Added external typing support to the helper module, code from import pybind11 can now be type checked. #2588
    • Minimum CMake required increased to 3.4. #2338 and #2370
      • 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 versions.
      • Virtual environments prioritized if PYTHON_EXECUTABLE is not set (venv, virtualenv, and conda) (similar to the new FindPython mode).
      • Other CMake features now natively supported, like CMAKE_INTERPROCEDURAL_OPTIMIZATION, set(CMAKE_CXX_VISIBILITY_PRESET hidden).
      • CUDA as a language is now supported.
      • Helper functions pybind11_strip, pybind11_extension, pybind11_find_import added, see cmake/index.
      • Optional find-python-mode and nopython-mode with CMake. #2370
    • Uninstall target added. #2265 and #2346
    • pybind11_add_module() now accepts an optional OPT_SIZE flag that switches the binding target to size-based optimization if the global build type can not always be fixed to MinSizeRel (except in debug mode, where optimizations remain disabled). MinSizeRel or this flag reduces binary size quite substantially (~25% on some platforms). #2463

    Smaller or developer focused features and fixes:

    • Moved mkdoc.py to a new repo, pybind11-mkdoc. There are no longer submodules in the main repo.
    • py::memoryview segfault fix and update, with new py::memoryview::from_memory in Python 3, and documentation. #2223
    • Fix for buffer_info on Python 2. #2503
    • If __eq__ defined but not __hash__, __hash__ is now set to None. #2291
    • py::ellipsis now also works on Python 2. #2360
    • Pointer to std::tuple & std::pair supported in cast. #2334
    • Small fixes in NumPy support. py::array now uses py::ssize_t as first argument type. #2293
    • Added missing signature for py::array. #2363
    • unchecked_mutable_reference has access to operator () and [] when const. #2514
    • py::vectorize is now supported on functions that return void. #1969
    • py::capsule supports get_pointer and set_pointer. #1131
    • Fix crash when different instances share the same pointer of the same type. #2252
    • Fix for py::len not clearing Python's error state when it fails and throws. #2575
    • Bugfixes related to more extensive testing, new GitHub Actions CI. #2321
    • Bug in timezone issue in Eastern hemisphere midnight fixed. #2438
    • std::chrono::time_point now works when the resolution is not the same as the system. #2481
    • Bug fixed where py::array_t could accept arrays that did not match the requested ordering. #2484
    • Avoid a segfault on some compilers when types are removed in Python. #2564
    • py::arg::none() is now also respected when passing keyword arguments. #2611
    • PyPy fixes, PyPy 7.3.x now supported, including PyPy3. (Known issue with PyPy2 and Windows #2596). #2146
    • CPython 3.9.0 workaround for undefined behavior (macOS segfault). #2576
    • CPython 3.9 warning fixes. #2253
    • Improved C++20 support, now tested in CI. #2489 #2599
    • Improved but still incomplete debug Python interpreter support. #2025
    • NVCC (CUDA 11) now supported and tested in CI. #2461
    • NVIDIA PGI compilers now supported and tested in CI. #2475
    • At least Intel 18 now explicitly required when compiling with Intel. #2577
    • Extensive style checking in CI, with pre-commit support. Code modernization, checked by clang-tidy.
    • Expanded docs, including new main page, new installing section, and CMake helpers page, along with over a dozen new sections on existing pages.
    • In GitHub, new docs for contributing and new issue templates.
    Source code(tar.gz)
    Source code(zip)
  • v2.6.0rc3(Oct 16, 2020)

    Next release candidate.

    • Factory constructor scope fix
    • Support for PyPy3 on Windows 32, added to CI
    • Fixes for C++20, added to CI for Clang, GCC, and MSVC 2019
    • Black formatting for all Python code
    • Allow ABI string overrides from 2.4 (advanced)
    Source code(tar.gz)
    Source code(zip)
  • v2.6.0rc2(Oct 14, 2020)

    Next release candidate. Changes since RC 1:

    Fixed:

    • Python 3.9.0 bug workaround implemented
    • Better support in CMake for packing and cross-compiling
    • Fix for failing py::len leaving error state set
    • Intel 18+ explicitly required, an issue with Intel compilers fixed
    • Custom ipo flags disabled with RelWithDebInfo (use CMAKE_INTERPROCEDURAL_OPTIMIZATION for more control)
    • Possible duplicate linker flags fixed in setup_helpers
    • Changes to py::module_ constructor are no longer provisional.

    New features:

    • Static typing support for import pybind11
    Source code(tar.gz)
    Source code(zip)
  • v2.6.0rc1(Oct 9, 2020)

    This is the first release candidate for pybind11 2.6.0. Please see the new features in the changelog, such as revamped CMake and setuptools support, keyword and positional argument support, and a long list of features, fixes, and improvements. Full Python 3.9 support and enhanced C++20 support.

    Known issues:

    • py::module_ direct construction provisionally deprecated
    • Removing registered types can cause a segfault - old issue exposed by recent test additions; fix incoming
    • On Python 3.9.0 and macOS, pybind11 may segfault when closing the interpreter after running the test suite
    Source code(tar.gz)
    Source code(zip)
  • v2.6.0b1(Sep 30, 2020)

Owner
pybind
Seamless operability between C++ and Python
pybind
reproduces experiments from

Installation To enable importing of modules, from the parent directory execute: pip install -e . To install requirements: python -m pip install requir

Meta Research 15 Aug 11, 2022
Projeto para ajudar no aprendizado da linguagem Pyhon

Economize Este projeto tem o intuito de criar desáfios para a codificação em Python, fazendo com que haja um maior entendimento da linguagem em seu to

Lucas Cunha Rodrigues 1 Dec 16, 2021
CircuitPython Driver for Adafruit 24LC32 I2C EEPROM Breakout 32Kbit / 4 KB

Introduction CircuitPython driver for Adafruit 24LC32 I2C EEPROM Breakout Dependencies This driver depends on: Adafruit CircuitPython Bus Device Regis

Adafruit Industries 4 Oct 03, 2022
Mail Me My Social Media stats (SoMeMailMe)

Mail Me My Social Media follower count (SoMeMailMe) TikTok only show data 60 days back in time. With this repo you can easily scrape your follower cou

Daniel Wigh 1 Jan 07, 2022
A Python application that helps users determine their calorie intake, and automatically generates customized weekly meal and workout plans based on metrics computed using their physical parameters

A Python application that helps users determine their calorie intake, and automatically generates customized weekly meal and workout plans based on metrics computed using their physical parameters

Anam Iqbal 1 Jan 13, 2022
Holographic Declarative Memory for Python ACT-R

HDM This is the repository for the Holographic Declarative Memory (HDM) module for Python ACT-R. This repository contains: documentation: a paper, con

Carleton Cognitive Modeling Lab 1 Jan 17, 2022
Spyware baseado em Python para Windows que registra como atividades da janela em primeiro plano, entradas do teclado.

Spyware baseado em Python para Windows que registra como atividades da janela em primeiro plano, entradas do teclado. Além disso, é capaz de fazer capturas de tela e executar comandos do shell em seg

Tavares 1 Oct 29, 2021
MDAnalysis tool to calculate membrane curvature.

The MDAkit for membrane curvature analysis is part of the Google Summer of Code program and it is linked to a Code of Conduct.

MDAnalysis 19 Oct 20, 2022
KUIZ is a web application quiz where you can create/take a quiz for learning and sharing knowledge from various subjects, questions and answers.

KUIZ KUIZ is a web application quiz where you can create/take a quiz for learning and sharing knowledge from various subjects, questions and answers.

Thanatibordee Sihaboonthong 3 Sep 12, 2022
A simply program to find active jackbox.tv game codes

PeepingJack A simply program to find active jackbox.tv game codes How does this work? It uses a threadpool to loop through all possible codes in a ran

3 Mar 20, 2022
STAC in Jupyter Notebooks

stac-nb STAC in Jupyter Notebooks Install pip install stac-nb Usage To use stac-nb in a project, start Jupyter Lab (jupyter lab), create a new noteboo

Darren Wiens 32 Oct 04, 2022
🙌Kart of 210+ projects based on machine learning, deep learning, computer vision, natural language processing and all. Show your support by ✨ this repository.

ML-ProjectKart 📌 Repository This kart showcases the finest collection of all projects based on machine learning, deep learning, computer vision, natu

Prathima Kadari 203 Dec 28, 2022
Library for Memory Trace Statistics in Python

Memory Search Library for Memory Trace Statistics in Python The library uses tracemalloc as a core module, which is why it is only available for Pytho

Memory Search 1 Dec 20, 2021
This Python script can enumerate all URLs present in robots.txt files, and test whether they can be accessed or not.

Robots.txt tester With this script, you can enumerate all URLs present in robots.txt files, and test whether you can access them or not. Setup Clone t

Podalirius 32 Oct 10, 2022
Hspice-Wave-Generator is a tool used to quickly generate stimuli souces of hspice format

Hspice-Wave-Generator is a tool used to quickly generate stimuli souces of hspice format. All the stimuli sources are based on `pwl` function of HSPICE and the specific complex operations of writing

3 Aug 02, 2022
A basic layout of atm working of my local database

Software for working Banking service 😄 This project was developed for Banking service. mysql server is required To have mysql server on your system u

satya 1 Oct 21, 2021
Change your Windows background with this program safely & easily!

Background_Changer Table of Contents: About the Program Features Requirements Preview Credits Reach Me See Also About the Program: You can change your

Sina.f 0 Jul 14, 2022
A faster copy of nell's comet nuker

Astro a faster copy of nell's comet nuker also nell uses external libraries like it's cocaine man never learned to use ansi color codes (ily nell) (On

horrid 8 Aug 15, 2022
Gmvault: Backup and restore your gmail account

Gmvault: Backup and restore your gmail account Gmvault is a tool for backing up your gmail account and never lose email correspondence. Gmvault is ope

Guillaume Aubert 3.5k Jan 01, 2023
I³ Tracker for Essential Open Innovation Datasets

I³ Tracker for Essential Open Innovation Datasets This repository is set up to track, version, and contribute updates to the I³ Essential Open Innovat

1 Feb 08, 2022