Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
4a48afb3
Commit
4a48afb3
authored
Mar 09, 2016
by
Wenzel Jakob
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
doc updates
parent
de623a76
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
7 deletions
+38
-7
docs/cmake.rst
+18
-3
docs/faq.rst
+20
-4
No files found.
docs/cmake.rst
View file @
4a48afb3
Build systems
#############
Building with setuptools
========================
For projects on PyPI, building with setuptools is the way to go. Sylvain Corlay
has kindly provided an example project which shows how to set up everything,
including automatic generation of documentation using Sphinx. Please refer to
the [pbtest]_ repository.
.. [pbtest] https://github.com/pybind/pbtest
.. _cmake:
.. _cmake:
Building with CMake
Building with CMake
===================
===================
The following snippet should be a good starting point to create bindings across
For C++ codebases that already have an existing CMake-based build system, the
platforms. It assumes that the code is located in a file named :file:`example.cpp`,
following snippet should be a good starting point to create bindings across
and that the pybind11 repository is located in a subdirectory named :file:`pybind11`.
platforms. It assumes that the code is located in a file named
:file:`example.cpp`, and that the pybind11 repository is located in a
subdirectory named :file:`pybind11`.
.. code-block:: cmake
.. code-block:: cmake
...
...
docs/faq.rst
View file @
4a48afb3
...
@@ -30,8 +30,24 @@ provided by the caller -- in fact, it does nothing at all.
...
@@ -30,8 +30,24 @@ provided by the caller -- in fact, it does nothing at all.
def increment(i):
def increment(i):
i += 1 # nope..
i += 1 # nope..
pybind11 is also affected by such language-level conventions, which means
pybind11 is also affected by such language-level conventions, which means that
that binding ``increment`` or ``increment_ptr`` will also create Python functions that don't modify their arguments.
binding ``increment`` or ``increment_ptr`` will also create Python functions
that don't modify their arguments.
Although inconvenient, one workaround is to encapsulate the immutable types in
a custom type that does allow modifications.
An other alternative involves binding a small wrapper lambda function that
returns a tuple with all output arguments (see the remainder of the
documentation for examples on binding lambda functions). An example:
.. code-block:: cpp
int foo(int &i) { i++; return 123; }
and the binding code
.. code-block:: cpp
m.def("foo", [](int i) { int rv = foo(i); return std::make_tuple(rv, i); });
Although inconvenient, one workaround is to encapsulate the immutable types
in a custom type that does allow modifications.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment