-
-
Notifications
You must be signed in to change notification settings - Fork 712
Bring back itkVtkGlue to Python wrapping #5502
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
Bring back itkVtkGlue to Python wrapping #5502
Conversation
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.
Thank you for contributing a pull request! 🙏
Welcome to the ITK community! 🤗👋☀️
We are glad you are here and appreciate your contribution. Please keep in mind our community participation guidelines. 📜
More support and guidance on the contribution process can be found in our contributing guide. 📖
This is an automatic message. Allow for time for the ITK community to be able to read the pull request and comment
on it.
|
If this is patch set is meant to be included in the release branch, make |
|
If that is a lot of work, maybe wait for a review by Matt. |
|
|
||
| #Write compile definitions and include paths to file. @CONFIG_CASTXML_INC_CONTENTS@ expanded in configure_file | ||
| set(castxml_inc_file "${WRAPPER_LIBRARY_OUTPUT_DIR}/castxml_inputs/${library_name}.castxml.inc") | ||
| set(castxml_inc_file "${WRAPPER_LIBRARY_OUTPUT_DIR}/castxml_inputs/${WRAPPER_LIBRARY_NAME}.castxml.inc") |
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.
Can a further explanation be provided as to why this is changed and why the change does not impact other libraries and modules?
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.
ofc,
-
Why this is changed?
BUG: Restructured python type hint generation procedure #3200 reworked the Python wrapping code, and is the reason why itkVtkGlue couldn't be wrapped anymore.
If you take a look at this line you will see that the original code was in theitk_wrap_modulemacro directly, so it had access tolibrary_nameparameter. When the code has been moved to a different macrolibrary_namebecame empty (because macro arguments are not real variables, so they do not outlive the macro body).
UsingWRAPPER_LIBRARY_NAMEactually reverts back to the original behavior, where each module has its own include directories list, named<module-name>.castxml.inc. -
Why the change does not impact other libraries and modules?
Each module will have its own file, otherwise no behavior changed!
Note that this also fixes a subtle issue about incremental builds, because enabling or disabling a module with python wrapping caused all module wrapping to be rebuilt, because the .castxml.inc was modified, so all xml regenerated, and so on. With this change, the old behavior is restored, so already build modules shouldn't modify their own castxml.inc, so they won't be rebuilt for nothing!
Let me know if something is still unclear!
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.
The information here, especially about incremental builds, deserves to be in the commit message.
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.
I updated the commit description!
66bf521 to
a3f15ed
Compare
Indeed, I rebased on main! |
All module generated the same ".castxml.inc" file. This caused several issues: - Each CMake configure step repeatedly overwrote .castxml.inc, causing a full rebuild of all wrapping related files because the XML descriptions were considered out-of-date. - Wrapping of module itkVtkGlue failed, because it requires additional include directories that were removed by other modules. This change makes each module now generates its own "<module>.castxml.inc" file.
a3f15ed to
bcb6876
Compare
dzenanz
left a comment
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.
LGTM
|
Thank you Alexy! |
|
This PR broke some of the builds on the nightly dashboard. Error message (from configure step): More info here: https://open.cdash.org/builds/10653427 |
|
I am working on a fix locally. |
|
Fix in #5512. Passes configure step locally with VTK 8.2 and 9.4. |
|
There are also some build errors on Mac: |
|
This one might be harder to tackle, ITK enables the Python limited API by default when Python version is superior to 3.11 here and PyBufferProcs structure is defined in cpython/object.h that is only included when using the "unlimited" API here. Maybe we could enable the unlimited API just for VtkGlue module? |
|
The point of the limited API is compatibility of later versions with 3.11. We could make options |
|
Could we remove the dependence on PyBufferProcs? |
|
There are more errors, such as this: but not |
|
vtkkwiml is header-only so there won't be any archive or shared library for sure. This means that the target "vtkkwiml" is not found by CMake, so it is replaced with a random "-lvtkkwiml" (or windows equivalent). I don't see any reason why this target would be undefined though. Maybe a specific VTK version in which the module wasn't renamed yet? |
|
My local VTK was at 5e878068c23f6b87a398dbe8000424971dcb7afa. When I updated it to 9.5.1, |
|
The nightly builds (e.g. Windows11-VS2022-Static-DebugTBB) use VTK 8.2.0 built with VS 2015. They are still afflicted by |
| _required_vtk_libraries | ||
| ${_target_prefix}IOImage | ||
| ${_target_prefix}ImagingSources | ||
| ${_target_prefix}kwiml |
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.
We might need special handling for this, like we do for vtksys. But critical version might be different from 8.90.0. @AlexyPellegrini
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.
The critical version is probably much newer, as 5e87806, which is affected, is only 6 months old.
|
I created PR #5522, please review. |
Brief
Python wrapping of itkVtkGlue has been removed by #4392. This PR fixes the build issue and enables it again.
Issue
The XML generations failed because the response file referencing the include directories for castxml was not generated correctly. All modules used the same
.castxml.incinstead of their own<modulename>.castxml.inc. Once this is fixed, the module wraps correctly.Why is it needed
Even though numpy enables to share an itk::Image and a vtkImageData, it does not support pipelining. Pipelining is important because some VTK and ITK filters support requesting only a subextent of a resource, enabling better performances especially for readers of formats meant to be streamed, such as OME-Zarr.
PR Checklist
FYI @finetjul