Skip to content

Latest commit

 

History

History
84 lines (61 loc) · 2.34 KB

File metadata and controls

84 lines (61 loc) · 2.34 KB

unit pip ubuntu conda

cppwg

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.

Documentation

Full documentation is at https://chaste.github.io/cppwg/:

Installation

Install CastXML (required) and Clang (recommended). On Ubuntu:

sudo apt-get install castxml clang

Clone the repository and install cppwg:

git clone https://github.com/Chaste/cppwg.git
cd cppwg
pip install .

Quick start

Describe the package to generate in a YAML config:

name: pyshapes
modules:
  - name: primitives
    classes:
      - name: Rectangle

Generate 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++17

Then 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.

Building the docs locally

pip install ".[docs]"
sphinx-build -b html doc doc/_build/html

License

BSD 3-Clause. See LICENSE.