Automatically generate pybind11 Python wrapper code for C++ projects.
cppwg reads your C++ source together with a YAML configuration file and emits the pybind11 registration code for the classes, free functions, and template instantiations you select — so you describe what to expose in config rather than hand-writing wrapper code.
Full documentation is at https://chaste.github.io/cppwg/:
- Getting started — install, run, and a worked example.
- Configuration reference — every config option, with types and defaults.
- Custom generators — inject hand-written binding code.
- Tips & recipes.
Install CastXML (required) and Clang (recommended). On Ubuntu:
sudo apt-get install castxml clangClone the repository and install cppwg:
git clone https://github.com/Chaste/cppwg.git
cd cppwg
pip install .Describe the package to generate in a YAML config:
name: pyshapes
modules:
- name: primitives
classes:
- name: RectangleGenerate the wrappers:
cd examples/shapes
cppwg src/cpp \
--wrapper_root wrapper \
--package_info wrapper/package_info.yaml \
--includes src/cpp/geometry src/cpp/math_funcs src/cpp/primitives \
--std c++17Then compile them into a Python package and import it:
from pyshapes import Rectangle
r = Rectangle(4, 5)See the full walkthrough
and the runnable examples/shapes and examples/cells projects for the
complete picture.
pip install ".[docs]"
sphinx-build -b html doc doc/_build/htmlBSD 3-Clause. See LICENSE.