Skip to content

Chaste/cppwg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

517 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

An automatic Python wrapper generator for C++ code.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages