Skip to content

Generating Bindings

Kwabena Amponsah edited this page Apr 23, 2024 · 8 revisions

Overview

PyChaste uses the cppwg package to generate Pybind11 wrappers around Chaste classes. The cppwg package reads an input package_info.yaml configuration file to determine which classes to wrap. The guidance below describes how to generate PyChaste wrappers.

Setup cppwg

See the cppwg repository for setup instructions.

Setup Chaste and PyChaste

To generate bindings, cppwg needs the C++ headers from Chaste and its dependencies. See the Chaste install guides for instructions on installing Chaste dependencies.

Get the source code for Chaste and PyChaste:

git clone --recursive https://github.com/Chaste/Chaste.git
git clone --recursive https://github.com/Chaste/PyChaste.git Chaste/projects/PyChaste

Configure Chaste and PyChaste:

cd Chaste
mkdir build
cd build
cmake ..

Update the wrapper configuration

Modify the configuration in package_info.yaml to add new classes to be wrapped. See Structure of package_info for more details.

Generate the wrappers

The following calls cppwg to generate the wrappers:

make project_PyChaste_Python_Bindings

The wrappers will be written to PyChaste/dynamic/wrappers.

Compiling the wrappers

For a guide on compiling the wrappers into a Python module, see Building PyChaste from Source.