Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ repos:
rev: 24.2.0
hooks: # check conformance to black formatting
- id: black
#args: ['--diff', '-v', '--target-version', 'py39' ] # if run without arguments, will fail and will format the files
args: ['--target-version', 'py39' ] # Allow black to fail and provide auto-formatting to files that need it for compliance
#args: ['--diff', '-v', '--target-version', 'py310' ] # if run without arguments, will fail and will format the files
args: ['--target-version', 'py310' ] # Allow black to fail and provide auto-formatting to files that need it for compliance
exclude: ".*build.*|\\/ThirdParty\\/|\\/Data\\/"
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
hooks:
- id: pyupgrade
exclude: ".*build.*|\\/ThirdParty\\/|\\/Data\\/"
args: [--py39-plus]
args: [--py310-plus]
- repo: https://github.com/SimpleITK/CommentSpellCheck.git
rev: v0.4.4
hooks:
Expand Down
10 changes: 5 additions & 5 deletions Documentation/docs/contributing/python_packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Building ITK Python wheels requires the following:
- CMake >= 3.16
- Git
- C++ Compiler (see [scikit-build platform specific requirements](https://scikit-build.readthedocs.io/en/latest/generators.html))
- Python >= 3.9
- Python >= 3.10

## Automated Platform Scripts

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

pushd ITKPythonPackage
export MANYLINUX_VERSION=2014
./scripts/dockcross-manylinux-build-wheels.sh cp38
./scripts/dockcross-manylinux-build-wheels.sh cp310
[...]

ls -1 dist/
itk-5.3.0.dev20231108-cp38-cp38m-manylinux2014_x86_64.whl
itk-6.0.0.dev20260401-cp310-cp310-manylinux2014_x86_64.whl
```

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

./scripts/macpython-build-wheels.sh cp38
./scripts/macpython-build-wheels.sh cp310
[...]

ls -1 dist/
itk-5.3.0.dev20231108-cp38-cp38m-macosx_10_9_x86_64.whl
itk-6.0.0.dev20260401-cp310-cp310-macosx_11_0_arm64.whl
```

### Windows
Expand Down
2 changes: 1 addition & 1 deletion Testing/ContinuousIntegration/AzurePipelinesLinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ jobs:
displayName: "Checkout pull request HEAD"
- task: UsePythonVersion@0
inputs:
versionSpec: "3.9"
versionSpec: "3.10"
architecture: "x64"
- bash: |
set -x
Expand Down
2 changes: 1 addition & 1 deletion Wrapping/Generators/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ if(NOT EXTERNAL_WRAP_ITK_PROJECT)
)

configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/itkConfig.py.in"
"${CMAKE_CURRENT_SOURCE_DIR}/itkConfig.template.in.py"
"${ITK_WRAP_PYTHON_ROOT_BINARY_DIR}/itkConfig.py"
@ONLY
)
Expand Down
4 changes: 2 additions & 2 deletions Wrapping/Generators/Python/PyBase/pyBase.i
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import collections
from sys import version_info as _version_info
# Set values below to the same value as
# PYTHON_VERSION_MIN in ITKSetPython3Vars.cmake
if _version_info < (3, 9, 0):
raise RuntimeError("Python 3.9 or later required")
if _version_info < (3, 10, 0):
raise RuntimeError("Python 3.10 or later required")

from . import _ITKCommonPython
%}
Expand Down
5 changes: 2 additions & 3 deletions Wrapping/Generators/Python/itk/pyi_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from io import StringIO
from pathlib import Path, PurePath
import pickle
from typing import Union
import glob
import re
from collections import defaultdict
Expand Down Expand Up @@ -380,7 +379,7 @@ def write_class_proxy_pyi(
pyi_file.write(interfaces_code)


def unpack(file_names: [str], save_dir: str) -> Union[str, None]:
def unpack(file_names: [str], save_dir: str) -> str | None:
class_definitions = []

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


def merge(class_definitions: []) -> Union[ITKClass, None]:
def merge(class_definitions: []) -> ITKClass | None:
# Merge all the class files together to return one complete class.
if len(class_definitions) == 0:
return None
Expand Down
6 changes: 3 additions & 3 deletions Wrapping/Generators/Python/itk/support/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from sys import stderr as system_error_stream

# Required to work around weird import error with xarray
from typing import Any, Optional, Union
from typing import Any
from collections.abc import Sequence

import itkConfig
Expand Down Expand Up @@ -305,7 +305,7 @@ class ITKTemplateFeatures:
('Image', 'itk::Image', 'itkImageSS2', True, 'signed short,2'),
"""

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

Expand Down
3 changes: 1 addition & 2 deletions Wrapping/Generators/Python/itk/support/build_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from itk.support import types
from itk.support.template_class import itkTemplate, itkTemplateBase

from typing import Union
from itkConfig import ITK_GLOBAL_WRAPPING_BUILD_OPTIONS as _itkwrapbo

DIMS: list[int] = [int(s) for s in _itkwrapbo["ITK_WRAP_IMAGE_DIMS"] if s]
Expand Down Expand Up @@ -62,7 +61,7 @@
SCALARS: list[types.itkCType] = INTS + REALS
VECTORS: list[itkTemplate] = VECTOR_REALS + COV_VECTOR_REALS
COLORS: list[itkTemplate] = RGBS + RGBAS
ALL_TYPES: list[Union[types.itkCType, itkTemplate]] = (
ALL_TYPES: list[types.itkCType | itkTemplate] = (
COLORS + VECTORS + SCALARS + COMPLEX_REALS
)

Expand Down
Loading
Loading