Skip to content

Commit 4ef67cd

Browse files
authored
Merge pull request InsightSoftwareConsortium#297 from InsightSoftwareConsortium/strip-trailing-whitespace
strip trailing whitespace
2 parents 5180812 + 8d09462 commit 4ef67cd

29 files changed

Lines changed: 736 additions & 679 deletions

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
cmake_minimum_required(VERSION 3.16.3 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.26.6 FATAL_ERROR)
2+
# NOTE: 3.26.6 is the first cmake vesion to support Development.SABIModule
23

34
project(ITKPythonPackage CXX)
45

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# ITK Python Package
22

3-
This project provides a `setup.py` script to build ITK Python binary
4-
packages and infrastructure to build ITK external module Python
5-
packages.
3+
This project configures pyproject.toml files and manages environmental
4+
variables needed to build ITK Python binary wheels on MacOS, Linux, and Windows platforms.
5+
Scripts are available for both [ITK infrastructure](https://github.com/insightSoftwareConsortium/ITK) and
6+
ITK external module Python packages.
67

78
The Insight Toolkit (ITK) is an open-source, cross-platform system that provides developers
89
with an extensive suite of software tools for image analysis.
@@ -16,14 +17,14 @@ or at the [ITK GitHub homepage](https://github.com/insightSoftwareConsortium/ITK
1617
- [Frequently Asked Questions](#frequently-asked-questions)
1718
- [Additional Information](#additional-information)
1819

19-
## Using ITK Python Packages
20+
## Using ITK Python Packages (pre-built, or locally built)
2021

2122
ITKPythonPackage scripts can be used to produce [Python](https://www.python.org/) packages
2223
for ITK and ITK external modules. The resulting packages can be
2324
hosted on the [Python Package Index (PyPI)](https://pypi.org/)
2425
for easy distribution.
2526

26-
### Installation
27+
### Installation of pre-built packages
2728

2829
To install baseline ITK Python packages:
2930

docs/Build_ITK_Module_Python_packages.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Congratulations! Your packages can be installed with the commands::
100100
python -m pip install itk-<your-short-module-name>
101101

102102
where `itk-<your-short-module-name>` is the short name for your module that is
103-
specified in your setup.py file.
103+
specified in the configured `pyproject.toml` file.
104104

105105
Automate PyPI Package Uploads
106106
-----------------------------
@@ -118,7 +118,7 @@ and for the scope use::
118118
itk-<your-short-module-name>
119119

120120
where `<your-short-module-name>` is the short name for your module that is
121-
specified in your setup.py file. That scope will be available if you have
121+
specified in your configured `pyproject.toml` file. That scope will be available if you have
122122
already uploaded a first set of wheels via twine as described above; and that
123123
is the recommended approach. Otherwise, if you are creating the project at
124124
this time, choose an unlimited scope, but be careful with the created token.
@@ -137,7 +137,7 @@ individual package as a best practice.
137137
:alt: GitHub PyPI token secret
138138

139139
To push packages to PyPI, first, make sure to update the `version` for your
140-
package in the *setup.py* file. The initial version might be `0.1.0` or
140+
package in the *pyproject.toml* file. The initial version might be `0.1.0` or
141141
`1.0.0`. Subsequent versions should follow
142142
`semantic versioning <https://semver.org/>`_.
143143

docs/Build_ITK_Python_packages.rst

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ automated. The following sections outline how to use the associated scripts.
2121
Linux
2222
-----
2323

24-
On any linux distribution with docker and bash installed, running the script dockcross-manylinux-build-wheels.sh will create 64-bit wheels for both python 2.x and python 3.x in the dist directory.
24+
On any linux distribution with docker and bash installed, running the script dockcross-manylinux-build-wheels.sh will create 64-bit wheels for python 3.9+ in the dist directory.
2525

2626
For example::
2727

@@ -94,38 +94,39 @@ files are created and deleted quickly, which can result in Access Denied
9494
errors. Windows 10 ships with an antivirus application, Windows Defender, that
9595
is enabled by default.
9696

97-
sdist
98-
-----
99-
100-
To create source distributions, sdist's, that will be used by pip to compile a wheel for installation if a binary wheel is not available for the current Python version or platform::
101-
102-
$ python setup.py sdist --formats=gztar,zip
103-
[...]
104-
105-
$ ls -1 dist/
106-
itk-4.11.0.dev20170216.tar.gz
107-
itk-4.11.0.dev20170216.zip
108-
109-
Manual builds
110-
=============
111-
112-
Building ITK Python wheels
113-
--------------------------
114-
115-
Build the ITK Python wheel with the following command::
116-
117-
python3 -m venv build-itk
118-
./build-itk/bin/pip install --upgrade pip
119-
./build-itk/bin/pip install -r requirements-dev.txt numpy
120-
./build-itk/bin/python setup.py bdist_wheel
121-
122-
Build a wheel for a custom version of ITK
123-
-----------------------------------------
124-
125-
To build a wheel for a custom version of ITK, point to your ITK git repository
126-
with the `ITK_SOURCE_DIR` CMake variable::
127-
128-
./build-itk/bin/python setup.py bdist_wheel -- \
129-
-DITK_SOURCE_DIR:PATH=/path/to/ITKPythonPackage-core-build/ITK
130-
131-
Other CMake variables can also be passed with `-D` after the double dash.
97+
.. The below instructions are outdated and need to be re-written
98+
.. sdist
99+
.. -----
100+
..
101+
.. To create source distributions, sdist's, that will be used by pip to compile a wheel for installation if a binary wheel is not available for the current Python version or platform::
102+
..
103+
.. $ python setup.py sdist --formats=gztar,zip
104+
.. [...]
105+
..
106+
.. $ ls -1 dist/
107+
.. itk-4.11.0.dev20170216.tar.gz
108+
.. itk-4.11.0.dev20170216.zip
109+
..
110+
.. Manual builds
111+
.. =============
112+
..
113+
.. Building ITK Python wheels
114+
.. --------------------------
115+
..
116+
.. Build the ITK Python wheel with the following command::
117+
..
118+
.. python3 -m venv build-itk
119+
.. ./build-itk/bin/pip install --upgrade pip
120+
.. ./build-itk/bin/pip install -r requirements-dev.txt numpy
121+
.. ./build-itk/bin/python setup.py bdist_wheel
122+
..
123+
.. Build a wheel for a custom version of ITK
124+
.. -----------------------------------------
125+
..
126+
.. To build a wheel for a custom version of ITK, point to your ITK git repository
127+
.. with the `ITK_SOURCE_DIR` CMake variable::
128+
..
129+
.. ./build-itk/bin/python setup.py bdist_wheel -- \
130+
.. -DITK_SOURCE_DIR:PATH=/path/to/ITKPythonPackage-core-build/ITK
131+
..
132+
.. Other CMake variables can also be passed with `-D` after the double dash.

docs/code/CompareITKTypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
import itk
44

5-
itk.F == itk.ctype('float') # True
5+
itk.F == itk.ctype("float") # True

docs/code/CreateBaseline.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import itk
44
import sys
55

6-
image = itk.Image[itk.UC,2].New()
7-
image.SetRegions([10,10])
8-
image.SetOrigin([0,0])
9-
image.SetSpacing([0.5,0.5])
6+
image = itk.Image[itk.UC, 2].New()
7+
image.SetRegions([10, 10])
8+
image.SetOrigin([0, 0])
9+
image.SetSpacing([0.5, 0.5])
1010
image.Allocate()
1111
image.FillBuffer(1)
1212
itk.imwrite(image, sys.argv[1])

docs/code/ExplicitInstantiation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# An apriori ImageType
99
PixelType = itk.F
10-
ImageType = itk.Image[PixelType,2]
10+
ImageType = itk.Image[PixelType, 2]
1111
image = itk.imread(input_filename, PixelType)
1212

1313
# An image type dynamically determined from the type on disk

docs/code/InstantiateITKObjects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import itk
44

55
# Instantiate SmartPointer objects
6-
InputType = itk.Image[itk.F,3]
7-
OutputType = itk.Image[itk.F,3]
6+
InputType = itk.Image[itk.F, 3]
7+
OutputType = itk.Image[itk.F, 3]
88
median = itk.MedianImageFilter[InputType, OutputType].New()
99

1010
# Instantiate non-SmartPointer objects

docs/code/MixingITKAndNumPy.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import sys
44
from pathlib import Path
55

6-
data_dir = Path(__file__).parent.resolve() / '..' / 'data'
6+
data_dir = Path(__file__).parent.resolve() / ".." / "data"
77

88
input_image_filename = sys.argv[1]
99
temp_dir = Path(input_image_filename).parent
1010
output_image_filename = sys.argv[2]
11-
input_mesh_filename = data_dir / 'cow.vtk'
12-
output_mesh_filename = temp_dir / 'cow.vtk'
13-
input_transform_filename = data_dir / 'rigid.tfm'
14-
output_transform_filename = temp_dir / 'rigid.tfm'
11+
input_mesh_filename = data_dir / "cow.vtk"
12+
output_mesh_filename = temp_dir / "cow.vtk"
13+
input_transform_filename = data_dir / "rigid.tfm"
14+
output_transform_filename = temp_dir / "rigid.tfm"
1515

1616
import itk
1717
import numpy as np
@@ -116,7 +116,7 @@
116116

117117

118118
# VNL matrix from np.ndarray
119-
arr = np.zeros([3,3], np.uint8)
119+
arr = np.zeros([3, 3], np.uint8)
120120
matrix = itk.vnl_matrix_from_array(arr)
121121

122122
# Array from VNL matrix

docs/code/test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@
66
import tempfile
77
import shutil
88

9+
910
def add_test(cmd):
1011
cmd.insert(0, sys.executable)
1112
subprocess.check_call(cmd)
1213

14+
1315
def cleanup(files):
1416
for f in files:
1517
if os.path.isdir(f):
1618
shutil.rmtree(f)
1719
else:
1820
os.remove(f)
1921

22+
2023
# Create temporary folder to save output images
2124
temp_folder = tempfile.mkdtemp()
2225
# Change current working directory to find scripts

0 commit comments

Comments
 (0)