|
2 | 2 | [](https://pypi.org/project/libigl/) |
3 | 3 | [](https://github.com/libigl/libigl-python-bindings/actions/workflows/wheels.yml?query=branch%3Amain) |
4 | 4 |
|
5 | | - |
6 | | -This repository contains the source code for the libigl Python bindings. These bindings are fully compatible with NumPy and SciPy and offer a convenient interface similar to functions in those libraries. |
7 | | - |
8 | | -These bindings are still under active development and should still be considered alpha quality. We encourage users to post issues so we can improve the bindings! |
| 5 | +This repository contains the source code for the libigl Python bindings written |
| 6 | +using [nanobind](https://nanobind.readthedocs.io/en/latest/). Functions allow |
| 7 | +NumPy arrays as input and output for dense matrices and vectors and SciPy sparse |
| 8 | +matrices for sparse matrices. |
9 | 9 |
|
10 | 10 | ## Installation |
11 | 11 |
|
12 | 12 | ``` |
13 | 13 | python -m pip install libigl |
14 | 14 | ``` |
15 | 15 |
|
16 | | -If you wish to install the current development code, you can compile the library from scratch. Clone this repo and issue |
17 | | - |
18 | | -``` |
19 | | -python -m pip install ./ |
20 | | -``` |
21 | | - |
22 | | - |
23 | 16 | ## [Help/Documentation](https://libigl.github.io/libigl-python-bindings/) |
24 | 17 |
|
| 18 | +| :warning: WARNING | |
| 19 | +|:----------------------------| |
| 20 | +| This documentation is perennially out of date and will likely be removed/changed. | |
| 21 | + |
25 | 22 | * A tutorial on how to use the bindings can be found [here](https://libigl.github.io/libigl-python-bindings/tutorials/) |
26 | 23 | * A function reference can be found [here](https://libigl.github.io/libigl-python-bindings/igl_docs/) |
27 | 24 |
|
@@ -50,9 +47,36 @@ According to the [scikit-build-core documentation](https://scikit-build-core.rea |
50 | 47 | python -m pip install --no-build-isolation --config-settings=editable.rebuild=true -Cbuild-dir=build -ve. |
51 | 48 | ``` |
52 | 49 |
|
| 50 | +### Adding a missing binding |
| 51 | + |
| 52 | +Bindings are fairly mechanical to write. For example, suppose we didn't have a |
| 53 | +binding for the c++ function `igl::moments`. The first step would be to look at |
| 54 | +the corresponding `.h` header file in the C++ libigl library: |
| 55 | +[moments.h](https://github.com/libigl/libigl/blob/main/include/igl/moments.h). |
| 56 | + |
| 57 | +Then we would create the [src/moments.cpp](src/moments.cpp) file in this project |
| 58 | +which uses `Eigen::MatrixXN` for numeric types and `Eigen::MatrixXI` for integer |
| 59 | +types. Typically this requires a simple wrapper around the function matching |
| 60 | +its signature to these types and some boilerplate `void bind_moments(...` code which adds the function to the python module. |
| 61 | + |
| 62 | +Simply adding this `.cpp` file will be enough to add the bindings on the next |
| 63 | +build. |
| 64 | + |
| 65 | +If submitting a pull request with a new binding, please also add an execution |
| 66 | +test in `tests/test_all.py` to ensure the binding can at least be called as |
| 67 | +expected. |
| 68 | + |
| 69 | + |
53 | 70 | ## Testing cibuildwheel locally |
54 | 71 |
|
55 | 72 | Install whichever version of Python from the [official website](https://www.python.org/downloads/) and then run: |
56 | 73 |
|
57 | 74 | /Library/Frameworks/Python.framework/Versions/[version]/bin/python -m pip install cibuildwheel |
58 | 75 | CIBW_BUILD="cp311-*" python -m cibuildwheel --output-dir wheelhouse --platform macos |
| 76 | + |
| 77 | +## Acknowledgements |
| 78 | + |
| 79 | +The original python bindings were generated and maintained by @teseoch, |
| 80 | +@KarlLeell, @fwilliams, @skoch9, @danielepanozzo. |
| 81 | + |
| 82 | +The modern python bindings (since 2.5.4.dev0) can largely be blamed on @alecjacobson. |
0 commit comments