-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop NumPy build dependency #751
Drop NumPy build dependency #751
Conversation
As this appears unused, go ahead and drop it.
Looks like this code might need some tweaks if we proceed further cucim/python/pybind11/cucim_py.cpp Line 448 in 0e75c76
Edit: Changes below rewrite this to use a |
As `py::memoryview` must be assigned and we cannot guarantee it will assign without error, declare `py::object` and place the results of `py::memoryview` (if successful) into `py::object`. Can reconstruct the `py::memoryview` later to get the actual object out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jakirkham ! It looks good to me.
I have a question: Did pybind11/numpy.h
depends on numpy header or numpy library?
If this change is about for handling numpy 2,
can upgrading pybind11 library to the latest version helps?
Looks like pybind11 is handling numpy 2 case - https://github.com/pybind/pybind11/blob/master/include/pybind11/numpy.h#L187
A few things to unpack here NumPy is atypical in its setup. When building against NumPy, one only However the symbols that the NumPy header names are in the Python shared objects that the NumPy package ships. Those symbols get loaded when calling Regardless, from a developer's perspective, building against NumPy always means using the header and the libraries. There isn't a way to pick just one or the other Using pybind11 for NumPy support is not unique in this regard
Yes, it is true that pybind11 2.12.0 ships with NumPy 2 support. Building against that would be sufficient for NumPy 1 & 2 support (without other changes) That said, there are relatively few cases where the NumPy API is strictly needed. Especially after the introduction of the Python Buffer Protocol. Many use cases (and ours in cuCIM is one of these) simply need a way to access the underlying memory buffer of Python objects (NumPy arrays or otherwise). So in these cases, it is better to use the Python Buffer Protocol directly (as this code change does), which works not only with NumPy arrays, but any object that supports the Python Buffer Protocol. As a result this simplifies our dependencies. Plus this approach is more flexible and interoperable with other libraries |
Thanks @jakirkham for the comprehensive explanation! |
/merge |
Thanks all! 🙏 |
Partially addresses issue: rapidsai/build-planning#82
Partially addresses issue: rapidsai/build-planning#41
Even though cuCIM currently
#include
s<pybind11/numpy.h>
, the actual C++ code appears not to use NumPy. So this attempts to drop the header and the NumPy build dependency.