Repository navigation
BUG: Register VTK's DLL directory at import itk on Windows - #7059
Merged
Merged
Conversation
dzenanz
marked this pull request as ready for review
November 1, 2026 14:24
Contributor
[Medium impact] The change reaches Windows users of Python-wrapped ITKVtkGlue. Fix the generated path quoting before merging; a valid Windows directory can currently prevent ITK from importing. Findings
|
Python >= 3.8 ignores PATH for an extension's dependent DLLs, so _ITKVtkGluePython failed to load and itk.force_load() raised ImportError. vtkmodules registers only <prefix>/bin, which misses the bin/<config> directory of a multi-config VTK build tree. ITKVtkGlueConfig.py, which import itk loads, now adds the directory of VTK::CommonCore, so it is registered before VtkGlue or vtkmodules loads.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows,
import itk; itk.force_load()failed withDLL load failed while importing _ITKVtkGluePythonagainst a multi-config VTK build tree.ITKVtkGlueConfig.pynow registers VTK's DLL directory, so users don't needos.add_dll_directoryor animport vtkmodulesfirst.Root cause
Python >= 3.8 ignores
PATHfor an extension's dependent DLLs.vtkmodulesonly registers<prefix>/bin, but Visual Studio builds of VTK put their DLLs inbin/<config>. A complementary VTK change adds those directories tovtkmodules/_build_paths.py. The two changes don't conflict: registering the same directory twice is harmless.import itkimports everyitk/Configuration/*Config.py, so a newITK_WRAP_PYTHON_CONFIGURATION_PREAMBLEplaceholder inModuleConfig.py.inruns before VtkGlue orvtkmodulesloads. Modules that leave it empty generate the same file as before. VtkGlue sets it on Windows only, to the directory ofVTK::CommonCoreforCMAKE_BUILD_TYPE, or for Release in multi-config builds.No CI configuration enables
Module_ITKVtkGlue, which is why CI didn't catch this.AI assistance
VTK_DIRpointing to a VTK 9.7 VS2022 build tree:PythonVtkGlue*,PythonFindEmptyClasses,PythonGetNameOfClass,PythonTiming,PythonBuildOptions,PythonVerify*APIConsistency,PythonTypeTestandPythonExtrasTestall pass (11/11).🤖 Generated with Claude Code