Skip to content

COMP: Raise minimum wrapped Python to 3.11 - #6490

Merged
hjmjohnson merged 5 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:python-311-floor
Jun 22, 2026
Merged

hjmjohnson merged 5 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:python-311-floor

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

Raises ITK's minimum wrapped Python from 3.10 to 3.11 across build, CI, runtime guards, and docs, and removes the now-dead 3.10 codepaths. Deliberately leaves the Python limited-API (SABI) configuration untouched so it composes cleanly with the in-flight SWIG 4.4.1 work (#6484).

Commits
Commit Prefix What
b0ee513 COMP CMake floor PYTHON_VERSION_MIN 3.10→3.11
fc698e6 COMP Azure Linux/LinuxPython/Batch pipelines 3.10→3.11; BumpITKVersionInCI.sh wheel matrix drops 3.10
d9fbaa9 COMP Import-time version guards in igenerator.py + pyBase.i → (3, 11, 0)
40c2f63 DOC python_packaging.md minimum >= 3.11 + cp310→cp311 examples
14ebbd1 COMP Drop dead "3.10-3.11" references in __buffer__/__array__ docstrings + a test comment
e6e8af2 ENH Explicit typing.TypeAlias on itk.support.types aliases (PEP 613, now guaranteed at 3.11)
Scope & coordination
Verification
  • pre-commit run --all-files → clean (exit 0, no modifications)
  • pixi run build-python (CPython 3.13.9) → exit 0; import itk succeeds (exercises the bumped runtime guards); functional smoke (filled image → numpy view) passes
  • Configure confirms the floor: found suitable version "3.13.9", required range is "3.11...3.999"

Bump PYTHON_VERSION_MIN so FindPython3 requires CPython 3.11+ when
building the Python wrapping. First step in retiring 3.10 support.
@github-actions github-actions Bot added type:Compiler Compiler support or related warnings type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots area:Python wrapping Python bindings for a class type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Core Issues affecting the Core module area:Documentation Issues affecting the Documentation module labels Jun 22, 2026

@dzenanz dzenanz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good. I don't really understand the last commit.

Comment thread Utilities/Maintenance/BumpITKVersionInCI.sh Outdated

ls -1 dist/
itk-6.0.0.dev20260401-cp310-cp310-manylinux2014_x86_64.whl
itk-6.0.0.dev20260401-cp311-cp311-manylinux2014_x86_64.whl

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to update these dates.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Rather than swap in another concrete date that will just go stale again, I've replaced the rot-prone version+date segment with a descriptive placeholder:

itk-<ITK_VERSION>-cp311-cp311-manylinux2014_x86_64.whl
itk-<ITK_VERSION>-cp311-cp311-macosx_11_0_arm64.whl

The cp311 tag stays concrete since it's the literal argument passed to the build script just above, so the example still shows cause and effect. This avoids the "comment rot" of hard-coded 6.0.0.devYYYYMMDD strings that were already stale on main.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expanded the placeholders to cover every variable field per the binary distribution format:

itk-<ITK_VERSION>-cp<PYTAG>-cp<PYTAG>-manylinux<MANYLINUX_VERSION>_<ARCH>.whl
itk-<ITK_VERSION>-cp<PYTAG>-cp<PYTAG>-macosx_<MACOS_VERSION>_<ARCH>.whl

Added a short legend under the Linux example mapping each placeholder (<ITK_VERSION> release vs X.Y.Z.devYYYYMMDD dev build, <PYTAG> CPython tag, platform tag = ABI baseline + OS + arch). <MANYLINUX_VERSION> ties back to the MANYLINUX_VERSION env var set just above. Nothing hard-coded left to rot.

@hjmjohnson

hjmjohnson commented Jun 22, 2026 •

Copy link
Copy Markdown
Member Author

You're correct, that last commit is a little bit out of scope for this PR.

The last commit annotates the itk.support.types aliases (Image = "itk.Image", etc.) with an explicit : TypeAlias (PEP 613). Those aliases have carried a standing TODO since 2021 (commit 22827a5e972): "These should eventually explicitly be marked as TypeAlias's per PEP 613, available in CPython 3.10." Because typing.TypeAlias needs CPython ≥ 3.10, raising the floor to 3.11 here is what finally unblocks it, so it rode along. It resolves the "Variable is not valid as a type" diagnostic that type checkers emit for the implicit string aliases.

But you're right that it's a separate concern from the version-floor enforcement, and it deserves its own validation (mypy/pyright before-and-after evidence) that this PR's CI doesn't provide. I'll drop it from here and bring it back as a focused follow-up PR once this lands.

Bump the three Azure pipelines still pinned to 3.10 (Linux, LinuxPython,
Batch) up to 3.11, matching the new wrapping floor. Advance the
BumpITKVersionInCI.sh wheel matrix to drop 3.10.
Bump the import-time version check emitted into every wrapped module
(igenerator.py) and the static pyBase.i guard to match PYTHON_VERSION_MIN.
Update the python_packaging contributing guide to match the new
PYTHON_VERSION_MIN. Historical release notes are left untouched.
With the 3.11 floor the "3.10-3.11" branch in the __buffer__/__array__
docstrings no longer applies; describe only the supported 3.11 behavior.
@hjmjohnson
hjmjohnson requested a review from dzenanz June 22, 2026 20:36
@hjmjohnson
hjmjohnson marked this pull request as ready for review June 22, 2026 20:36
@greptile-apps

greptile-apps Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR raises the minimum wrapped Python from 3.10 to 3.11 consistently across the CMake floor (PYTHON_VERSION_MIN), import-time runtime guards in pyBase.i and igenerator.py, three Azure CI pipelines, the wheel-bump maintenance script, and documentation. Dead "3.10-3.11" docstring and comment references are trimmed to "3.11".

  • CMake, runtime guards, CI pipelines, and docs are all updated in lock-step with the new 3.11 floor.
  • The PR description lists a sixth commit (e6e8af2) that was to add explicit typing.TypeAlias annotations to itk/support/types.py, but that file does not appear in the diff — the stale CPython 3.10 comment on line 185 of types.py is concrete evidence the commit did not land.
  • No other 3.10 references were found in the CI YAML files after the bump.

Confidence Score: 4/5

All the load-bearing changes (CMake floor, runtime guards, CI pipelines) are correct and self-consistent; the only gap is that the types.py TypeAlias migration described in the PR's commit table was not actually included in the diff.

The six commits listed in the PR description include one — e6e8af2 adding typing.TypeAlias to itk/support/types.py — whose changes do not appear anywhere in the diff. The file retains its old comment referencing CPython 3.10 and no TypeAlias annotations were added. Everything else in the PR lands cleanly: CMake, runtime guards, three CI pipelines, the bump script, and docs are all updated correctly and no stray 3.10 references remain in CI YAML files.

Wrapping/Generators/Python/itk/support/types.py — the TypeAlias migration described in the PR was not applied to this file.

Important Files Changed

Filename Overview
CMake/ITKSetPython3Vars.cmake Single-line bump of PYTHON_VERSION_MIN from 3.10 to 3.11; correct and consistent with all other changes.
Wrapping/Generators/Python/PyBase/pyBase.i Runtime version guard updated to (3, 11, 0) and two docstring version-range references trimmed from "3.10-3.11" to "3.11".
Wrapping/Generators/SwigInterface/igenerator.py Generated-header runtime guard bumped from (3, 10, 0) to (3, 11, 0); mirrors the pyBase.i change correctly.
Testing/ContinuousIntegration/AzurePipelinesBatch.yml UsePythonVersion versionSpec bumped from 3.10 to 3.11.
Testing/ContinuousIntegration/AzurePipelinesLinux.yml UsePythonVersion versionSpec bumped from 3.10 to 3.11.
Testing/ContinuousIntegration/AzurePipelinesLinuxPython.yml UsePythonVersion versionSpec bumped from 3.10 to 3.11.
Utilities/Maintenance/BumpITKVersionInCI.sh Wheel matrix sed patterns updated from [310, 311]/[10, 11] to [311, 312]/[11, 12]; comment updated accordingly.
Documentation/docs/contributing/python_packaging.md Minimum Python version updated from 3.10 to 3.11 in prose and example wheel script invocations; example wheel filenames replaced with a parameterized template.
Modules/Core/Common/wrapping/test/itkImageLifetimeTest.py Test comment updated from "3.10-3.11 primary path" to "3.11 primary path" to match the new floor.

Reviews (1): Last reviewed commit: "COMP: Drop dead Python 3.10 references f..." | Re-trigger Greptile

@dzenanz dzenanz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good as-is. I am indecisive about concrete version number.


ls -1 dist/
itk-6.0.0.dev20260401-cp310-cp310-manylinux2014_x86_64.whl
itk-<ITK_VERSION>-cp<PYTAG>-cp<PYTAG>-manylinux<MANYLINUX_VERSION>_<ARCH>.whl

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A concrete version number has documentary value too, even if it is out of date.

@hjmjohnson
hjmjohnson merged commit 6fc0363 into InsightSoftwareConsortium:main Jun 22, 2026
20 of 22 checks passed
@hjmjohnson
hjmjohnson deleted the python-311-floor branch August 22, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Core Issues affecting the Core module area:Documentation Issues affecting the Documentation module area:Python wrapping Python bindings for a class type:Compiler Compiler support or related warnings type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants