This repository contains the source code for the python bindings for the C++
libigl library written using
nanobind. Functions allow NumPy
arrays as input and output for dense matrices and vectors and SciPy sparse
matrices for sparse matrices.
Getting the current version of libigl within python code
Since version 2.5.4.dev0, the igl.__version__ attribute has been removed. To
get the version of the libigl package you're using within your python code, you
can use the following code:
The CMAKE_BUILD_PARALLEL_LEVEL=10 will invoke with 10 parallel build threads.
Adding a missing binding
Bindings are fairly mechanical to write. For example, suppose we didn't have a
binding for the c++ function igl::moments. The first step would be to look at
the corresponding .h header file in the C++ libigl library:
moments.h.
Then we would create the src/moments.cpp file in this project
which uses Eigen::MatrixXN for numeric types and Eigen::MatrixXI for integer
types. Typically this requires a simple wrapper around the function matching
its signature to these types and some boilerplate void bind_moments(... code which adds the function to the python module.
Simply adding this .cpp file will be enough to add the bindings on the next
build.
If submitting a pull request with a new binding, please also add an execution
test in tests/test_all.py to ensure the binding can at least be called as
expected.
Packaging a wheel from an existing build
If you already have a compiled build directory, you can package it into a
.whl without recompiling and install that wheel into other virtual
environments on the same machine:
The --no-deps flag skips bundling numpy/scipy (the target environment must
have them already). No compiler or CMake is required in the target environment.
Testing cibuildwheel locally
Install whichever version of Python from the official website and then run: