Skip to content

Commit 8a2451b

Browse files
authored
Merge pull request InsightSoftwareConsortium#6012 from hjmjohnson/enh/pre-commit-py310
ENH: Update to minimum Python support to py310
2 parents 80b191f + f413b6c commit 8a2451b

13 files changed

Lines changed: 83 additions & 83 deletions

File tree

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ repos:
7474
rev: 24.2.0
7575
hooks: # check conformance to black formatting
7676
- id: black
77-
#args: ['--diff', '-v', '--target-version', 'py39' ] # if run without arguments, will fail and will format the files
78-
args: ['--target-version', 'py39' ] # Allow black to fail and provide auto-formatting to files that need it for compliance
77+
#args: ['--diff', '-v', '--target-version', 'py310' ] # if run without arguments, will fail and will format the files
78+
args: ['--target-version', 'py310' ] # Allow black to fail and provide auto-formatting to files that need it for compliance
7979
exclude: ".*build.*|\\/ThirdParty\\/|\\/Data\\/"
8080
- repo: https://github.com/asottile/pyupgrade
8181
rev: v3.19.0
8282
hooks:
8383
- id: pyupgrade
8484
exclude: ".*build.*|\\/ThirdParty\\/|\\/Data\\/"
85-
args: [--py39-plus]
85+
args: [--py310-plus]
8686
- repo: https://github.com/SimpleITK/CommentSpellCheck.git
8787
rev: v0.4.4
8888
hooks:

Documentation/docs/contributing/python_packaging.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Building ITK Python wheels requires the following:
2020
- CMake >= 3.16
2121
- Git
2222
- C++ Compiler (see [scikit-build platform specific requirements](https://scikit-build.readthedocs.io/en/latest/generators.html))
23-
- Python >= 3.9
23+
- Python >= 3.10
2424

2525
## Automated Platform Scripts
2626

@@ -40,11 +40,11 @@ git clone https://github.com/InsightSoftwareConsortium/ITKPythonPackage.git
4040

4141
pushd ITKPythonPackage
4242
export MANYLINUX_VERSION=2014
43-
./scripts/dockcross-manylinux-build-wheels.sh cp38
43+
./scripts/dockcross-manylinux-build-wheels.sh cp310
4444
[...]
4545

4646
ls -1 dist/
47-
itk-5.3.0.dev20231108-cp38-cp38m-manylinux2014_x86_64.whl
47+
itk-6.0.0.dev20260401-cp310-cp310-manylinux2014_x86_64.whl
4848
```
4949

5050
### macOS
@@ -61,11 +61,11 @@ Then, run [macpython-build-wheels.sh](https://github.com/InsightSoftwareConsorti
6161
git clone https://github.com/InsightSoftwareConsortium/ITKPythonPackage.git
6262
[...]
6363

64-
./scripts/macpython-build-wheels.sh cp38
64+
./scripts/macpython-build-wheels.sh cp310
6565
[...]
6666

6767
ls -1 dist/
68-
itk-5.3.0.dev20231108-cp38-cp38m-macosx_10_9_x86_64.whl
68+
itk-6.0.0.dev20260401-cp310-cp310-macosx_11_0_arm64.whl
6969
```
7070

7171
### Windows

Testing/ContinuousIntegration/AzurePipelinesLinux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ jobs:
245245
displayName: "Checkout pull request HEAD"
246246
- task: UsePythonVersion@0
247247
inputs:
248-
versionSpec: "3.9"
248+
versionSpec: "3.10"
249249
architecture: "x64"
250250
- bash: |
251251
set -x

Wrapping/Generators/Python/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ if(NOT EXTERNAL_WRAP_ITK_PROJECT)
166166
)
167167

168168
configure_file(
169-
"${CMAKE_CURRENT_SOURCE_DIR}/itkConfig.py.in"
169+
"${CMAKE_CURRENT_SOURCE_DIR}/itkConfig.template.in.py"
170170
"${ITK_WRAP_PYTHON_ROOT_BINARY_DIR}/itkConfig.py"
171171
@ONLY
172172
)

Wrapping/Generators/Python/PyBase/pyBase.i

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import collections
1212
from sys import version_info as _version_info
1313
# Set values below to the same value as
1414
# PYTHON_VERSION_MIN in ITKSetPython3Vars.cmake
15-
if _version_info < (3, 9, 0):
16-
raise RuntimeError("Python 3.9 or later required")
15+
if _version_info < (3, 10, 0):
16+
raise RuntimeError("Python 3.10 or later required")
1717

1818
from . import _ITKCommonPython
1919
%}

Wrapping/Generators/Python/itk/pyi_generator.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from io import StringIO
1111
from pathlib import Path, PurePath
1212
import pickle
13-
from typing import Union
1413
import glob
1514
import re
1615
from collections import defaultdict
@@ -380,7 +379,7 @@ def write_class_proxy_pyi(
380379
pyi_file.write(interfaces_code)
381380

382381

383-
def unpack(file_names: [str], save_dir: str) -> Union[str, None]:
382+
def unpack(file_names: [str], save_dir: str) -> str | None:
384383
class_definitions = []
385384

386385
for file_name in file_names:
@@ -429,7 +428,7 @@ def unpack(file_names: [str], save_dir: str) -> Union[str, None]:
429428
return None
430429

431430

432-
def merge(class_definitions: []) -> Union[ITKClass, None]:
431+
def merge(class_definitions: []) -> ITKClass | None:
433432
# Merge all the class files together to return one complete class.
434433
if len(class_definitions) == 0:
435434
return None

Wrapping/Generators/Python/itk/support/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from sys import stderr as system_error_stream
2222

2323
# Required to work around weird import error with xarray
24-
from typing import Any, Optional, Union
24+
from typing import Any
2525
from collections.abc import Sequence
2626

2727
import itkConfig
@@ -305,7 +305,7 @@ class ITKTemplateFeatures:
305305
('Image', 'itk::Image', 'itkImageSS2', True, 'signed short,2'),
306306
"""
307307

308-
def __init__(self, feature_tuple: Sequence[Union[str, bool]]) -> None:
308+
def __init__(self, feature_tuple: Sequence[str | bool]) -> None:
309309
feature_length: int = len(feature_tuple)
310310
# ITK classes have exactly 5 elements in the tuple, otherwise they are swig classes
311311
self._is_itk_class: bool = feature_length == 5
@@ -317,7 +317,7 @@ def __init__(self, feature_tuple: Sequence[Union[str, bool]]) -> None:
317317
self._cpp_class_name: str = feature_tuple[1]
318318
self._swig_class_name: str = feature_tuple[2]
319319
self._class_in_module: bool = feature_tuple[3] if feature_length >= 4 else False
320-
self._template_parameters: Optional[str] = (
320+
self._template_parameters: str | None = (
321321
feature_tuple[4] if feature_length == 5 else None
322322
)
323323

Wrapping/Generators/Python/itk/support/build_options.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from itk.support import types
99
from itk.support.template_class import itkTemplate, itkTemplateBase
1010

11-
from typing import Union
1211
from itkConfig import ITK_GLOBAL_WRAPPING_BUILD_OPTIONS as _itkwrapbo
1312

1413
DIMS: list[int] = [int(s) for s in _itkwrapbo["ITK_WRAP_IMAGE_DIMS"] if s]
@@ -62,7 +61,7 @@
6261
SCALARS: list[types.itkCType] = INTS + REALS
6362
VECTORS: list[itkTemplate] = VECTOR_REALS + COV_VECTOR_REALS
6463
COLORS: list[itkTemplate] = RGBS + RGBAS
65-
ALL_TYPES: list[Union[types.itkCType, itkTemplate]] = (
64+
ALL_TYPES: list[types.itkCType | itkTemplate] = (
6665
COLORS + VECTORS + SCALARS + COMPLEX_REALS
6766
)
6867

0 commit comments

Comments
 (0)