Replace Boost.Python with pybind11 - #176
Conversation
Note: Moved BatchDropCutter::getTrianglesUnderCutter to pure cpp implementation
This reverts commit e894a13.
|
Hi @aewallin @vespakoen, just following up on this PR. If either of you happens to have some spare time, would you mind giving it a look or testing it out? I’d be happy to make any necessary changes. Thanks in advance! |
|
Hi @CalaW - not sure what you needed from this lib, but I built a set of wheels from your branch for Python 3.13 and uploaded them here if you want them: https://github.com/SpectralVectors/opencamlib/releases/tag/Python313_Wheels |
|
Cool! I will take a look at this next week, I hope to also upgrade Boost to the modern version which should remove a lot of the install script. |
|
Hi @vespakoen, Thanks for taking a look! Yes, Boost is still required. This PR only replaces Boost.Python with pybind11. We still use Boost.Graph, for example boost/graph/adjacency_list.hpp. I have already replaced some uses of BOOST_FOREACH, boost::tie, and Boost.Math with the standard library. I can also make another PR to replace the remaining ones. |
|
Removing boost completely would be great, it saves a lot of hassle with their somewhat weird build system. Boost did gain some better compatibility with CMake though, which might help. Maybe getting rid of Boost completely should be a follow up PR, I'd focus on getting this to work on all the platforms. Will look into this soon... |
|
Did you also consider nanobind? (https://github.com/wjakob/nanobind) it seems to be very similar in syntax so might be worth a try? |
|
Yes, I did consider nanobind. At that time, it was still relatively new, while pybind11 was already the de facto standard and had a much larger user base (3.4k vs 18k star). From what I have seen, nanobind does have some advantages, especially smaller binaries and lower binding overhead. However, for ocl, I believe most of the heavy computation happens in C++, so I don’t expect the Python binding overhead to be a bottleneck. |
|
I opened a pull request to your fork, If that lands I think I am fine with merging this. Let me know what you all think ;) EDIT: Just saw that the README also needs some updating |
|
Thanks! I will check your PR and update the README as well. I am not fully sure that the Python API is completely stable, because the project currently does not have a complete test framework for checking API compatibility. I run all python examples and test file and they looked fine. I tried to keep the exposed classes, functions, and method names the same, but there may still be some behavior differences. For example, opencamlib/src/pythonlib/adaptivewaterline_py.hpp Lines 50 to 60 in 95b036f However, the underlying C++ implementation inherits the behavior from Waterline, which returns the complete list: opencamlib/src/pythonlib/waterline_py.hpp Lines 53 to 61 in 95b036f In the pybind11 version, I preserved the behavior of the C++ implementation instead but it's still easy to modify. Speaking of versioning, I noticed that the current versioning seems to be date-based, with the latest release being |
This PR replaces Boost.Python with pybind11, which has become the de facto standard for Python bindings in C++.
Key improvements:
Note: This is still a draft. Documentation updates are pending. Please review the current changes and share your feedback. Once everyone is on board, I’ll proceed with updating the docs.
This should resolve #164.