BUG: Replace distutils.version with a standard-library comparison - #479
Open
hjmjohnson wants to merge 1 commit into
Open
BUG: Replace distutils.version with a standard-library comparison#479hjmjohnson wants to merge 1 commit into
hjmjohnson wants to merge 1 commit into
Conversation
hjmjohnson
marked this pull request as ready for review
September 12, 2026 13:59
hjmjohnson
force-pushed
the
comp-replace-distutils
branch
from
September 12, 2026 14:04
f49d826 to
fea7e67
Compare
hjmjohnson
force-pushed
the
comp-replace-distutils
branch
from
September 12, 2026 18:36
fea7e67 to
78ffaa7
Compare
Python 3.12 removed distutils, so every example guarding its minimum ITK
version with distutils.version.StrictVersion fails at import:
ModuleNotFoundError: No module named 'distutils'
Compare the dotted version components as a tuple instead, which needs no
import at all and keeps each example's existing minimum.
SegmentBloodVessels and
SegmentBloodVesselsWithMultiScaleHessianBasedMeasure called sys.exit()
in that guard without importing sys; add the import.
hjmjohnson
force-pushed
the
comp-replace-distutils
branch
from
September 12, 2026 18:38
78ffaa7 to
bae30bd
Compare
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.
Python 3.12 removed
distutils, which ten examples imported to check ITK'sversion. Compare the dotted components as a tuple instead, dropping the
import entirely.
The failure
Every affected example guards its minimum ITK version like this:
On Python 3.12 and newer the import raises before the example runs:
The replacement keeps each example's own minimum and drops the import:
Also fixed: a latent NameError in the same guard
SegmentBloodVesselsandSegmentBloodVesselsWithMultiScaleHessianBasedMeasurecallsys.exit()in that block without importingsys, so on an older ITK they would raiseNameErrorinstead of printing the message. Both now import it.Verification
Built against ITK
mainwith Python 3.14.6 and run through the project's own ctest Python suite:All eight
distutilscasualties pass. The two remaining failures are unrelated to this change and were failing beforehand:ConvolveImageWithKernelTestPythonneedsmatplotlib, which is absent from that environment, andComputeFFTInOneDimensionPhaseBaselineComparisonPythonfails a baseline image comparison (ImageError 25.13, 4 pixels).pre-commit run --all-filespasses, and nodistutilsreference remains in the repository.