Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interface with libtopotoolbox through scikit-build-core and pybind11 (#…
…12) The current approach using `ctypes` requires separately building and installing libtopotoolbox in an appropriate directory, which is tricky to get right in a cross-platform way without substantial intervention from users. This set of changes introduces a new build system using scikit-build-core and pybind11 to build an extension module that includes an interface to our library. pyproject.toml is modified to switch the build backend to scikit-build-core to install pybind11 as a build-time dependency. src/lib.cpp contains the bindings for libtopotoolbox, defined using pybind11. The PYBIND11_MODULE declaration exposes a Python module _lib within the topotoolbox package that contains the bindings. Right now, it only binds `has_topotoolbox`, which has a trivial binding because it requires no marshalling of Python data into C/C++ types. Other functions such as `fillsinks` will require more complex binding declarations, but pybind11 provides an interface to working with NumPy arrays that should be helpful. CMakeLists.txt is used by scikit-build-core to build the package. It follows the guidance at https://scikit-build-core.readthedocs.io/en/latest/getting_started.html with the exception of adding libtopotoolbox using FetchContent. This will download the source from GitHub and then build a /static/ library for libtopotoolbox and link it into the /shared/ library that is built by pybind11. src/topotoolbox/__init__.py shows how to access the binding from the _lib module. In practice, we probably don't want to expose the raw bindings from the topotoolbox module but instead use them to implement methods within the proposed `GridObject` class.
- Loading branch information