• Home
  • Raw
  • Download

Lines Matching refs:pybind11

18 A helper file is provided with pybind11 that can simplify usage with setuptools.
20 To use pybind11 inside your ``setup.py``, you have to have some system to
21 ensure that ``pybind11`` is installed when you build your package. There are
22 four possible ways to do this, and pybind11 supports all four: You can ask all
23 users to install pybind11 beforehand (bad), you can use
30 An example of a ``setup.py`` using pybind11's helpers:
36 from pybind11.setup_helpers import Pybind11Extension
58 from pybind11.setup_helpers import Pybind11Extension, build_ext
73 Since pybind11 does not require NumPy when building, a light-weight replacement
78 from pybind11.setup_helpers import ParallelCompile
101 from pybind11.setup_helpers import ParallelCompile, naive_recompile
129 ``pyproject.toml`` file, you can ensure that ``pybind11`` is available during
140 requires = ["setuptools>=42", "wheel", "pybind11~=2.6.1"]
164 ``setup_requires=["pybind11"]`` keyword argument to setup, which triggers a
172 from pybind11.setup_helpers import Pybind11Extension
191 set ``include_pybind11=False`` to skip including the pybind11 package headers,
197 Closely related, if you include pybind11 as a subproject, you can run the
199 the correct include for pybind11, though you can turn it off as shown above if
202 Suggested usage if you have pybind11 as a submodule in ``extern/pybind11``:
208 sys.path.append(os.path.join(DIR, "extern", "pybind11"))
209 from pybind11.setup_helpers import Pybind11Extension # noqa: E402
223 compiled as a Python extension using pybind11 and placed in the same folder as
241 add_subdirectory(pybind11)
244 This assumes that the pybind11 repository is located in a subdirectory named
245 :file:`pybind11` and that the code is located in a file named :file:`example.cpp`.
246 The CMake command ``add_subdirectory`` will import the pybind11 project which
263 To ease the creation of Python extension modules, pybind11 provides a CMake
284 Since pybind11 is a template library, ``pybind11_add_module`` adds compiler
287 sets default visibility to *hidden*, which is required for some pybind11
288 features and functionality when attempting to load multiple pybind11 modules
289 compiled under different pybind11 versions. It also adds additional flags
308 no-op) to disable pybind11's ipo flags.
328 By default, pybind11 will compile modules with the compiler default or the
329 minimum standard required by pybind11, whichever is higher. You can set the
362 For CMake-based projects that don't include the pybind11 repository internally,
363 an external installation can be detected through ``find_package(pybind11)``.
371 find_package(pybind11 REQUIRED)
374 Note that ``find_package(pybind11)`` will only work correctly if pybind11
376 the pybind11 repository :
381 cd pybind11
388 cd pybind11
395 if pybind11 is added as a subdirectory or found as an installed package. You
399 .. _Config file: https://github.com/pybind/pybind11/blob/master/tools/pybind11Config.cmake.in
409 and tools. If you use FindPython, pybind11 will detect this and use the
418 find_package(pybind11 CONFIG REQUIRED)
419 # or add_subdirectory(pybind11)
424 ``PYBIND11_FINDPYTHON``, pybind11 will perform the FindPython step for you
425 (mostly useful when building pybind11's own tests, or as a way to change search
456 ``pybind11::headers``
457 Just the pybind11 headers and minimum compile requirements
459 ``pybind11::python2_no_register``
462 ``pybind11::pybind11``
463 Python headers + ``pybind11::headers`` + ``pybind11::python2_no_register`` (Python 2 only)
465 ``pybind11::python_link_helper``
466 Just the "linking" part of pybind11:module
468 ``pybind11::module``
469 …verything for extension modules - ``pybind11::pybind11`` + ``Python::Module`` (FindPython CMake 3.…
471 ``pybind11::embed``
472 …Everything for embedding the Python interpreter - ``pybind11::pybind11`` + ``Python::Embed`` (Find…
474 ``pybind11::lto`` / ``pybind11::thin_lto``
477 ``pybind11::windows_extras``
480 ``pybind11::opt_size``
499 find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11)
503 target_link_libraries(example PRIVATE pybind11::module pybind11::lto pybind11::windows_extras)
515 Since pybind11 is a metatemplate library, it is crucial that certain
542 In addition to extension modules, pybind11 also supports embedding Python into
543 a C++ executable or library. In CMake, simply link with the ``pybind11::embed``
545 headers and libraries are attached to the target. Unlike ``pybind11::module``,
554 find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11)
557 target_link_libraries(example PRIVATE pybind11::embed)
564 pybind11 is a header-only library, hence it is not necessary to link against
572 …$ c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) example.cpp -o example$…
577 The ``python3 -m pybind11 --includes`` command fetches the include paths for
578 both pybind11 and Python headers. This assumes that pybind11 has been installed
580 ``-I <path-to-pybind11>/include`` together with the Python includes path
595 …$ c++ -O3 -Wall -shared -std=c++11 -undefined dynamic_lookup $(python3 -m pybind11 --includes) exa…
623 The ``Binder`` project is a tool for automatic generation of pybind11 binding
638 simplify creation of python wheels for pybind11 projects, and provide
640 customizable pybind11-based wrappers by parsing C++ header files.