This project provides a setup.py
script that can build, install, and package SimpleITK for Python. SimpleITK is a simplified programming layer on top of the Insight Segmentation and Registration Toolkit (ITK). ITK is an open-source, cross-platform system that provides developers with an extensive suite of software tools for image analysis.
SimpleITK is available for binary downloads from PyPI for many common platforms. Also a source distribution is available of this repository which may be used when an appropriate binary wheel is not available.
To install SimpleITK:
pip install SimpleITK
pip install --no-binary :all: SimpleITK
The build requirements are specified in the pyproject.toml file via PEP 518. The requirements should be automatically downloaded when using a PEP 517 compliant build front-end.
Additionally building requires:
- Git
- C++ Compiler - Platform specific requirements are summarized in scikit-build documentation.
- Python
- pip >= 9.0.0
Please ensure that pip
is up to date.
python -m pip install --upgrade pip
SimpleITK can be compiled and install directly from the github repository:
pip install git+https://github.com/SimpleITK/SimpleITKPythonPackage.git -v
Alternatively, SimpleITK for Python can be compiled and installed from the SimpleITKPythonPackage python source distribution.
pip install SimpleITKPythonPackage-1.0.0.tar.gz
The source distributions are available from PyPI.
Steps required to build wheels on Linux, MacOSX and Windows have been automated. The following sections outline how to use the associated scripts.
On any linux distribution with docker
and bash
installed, running the script
dockcross-manylinux-build-wheels.sh
will create 32 and 64-bit wheels for both
python 2.x and python 3.x in the dist
directory.
For example:
$ git clone git://github.com/SimpleITK/SimpleITKPythonPackage.git
[...]
$ ./scripts/dockcross-manylinux-build-wheels.sh
[...]
$ ls -1 dist/
SimpleITK-0.11.0-cp27-cp27m-manylinux1_i686.whl
SimpleITK-0.11.0-cp27-cp27m-manylinux1_x86_64.whl
SimpleITK-0.11.0-cp27-cp27mu-manylinux1_i686.whl
SimpleITK-0.11.0-cp27-cp27mu-manylinux1_x86_64.whl
SimpleITK-0.11.0-cp33-cp33m-manylinux1_i686.whl
SimpleITK-0.11.0-cp33-cp33m-manylinux1_x86_64.whl
SimpleITK-0.11.0-cp34-cp34m-manylinux1_i686.whl
SimpleITK-0.11.0-cp34-cp34m-manylinux1_x86_64.whl
SimpleITK-0.11.0-cp35-cp35m-manylinux1_i686.whl
SimpleITK-0.11.0-cp35-cp35m-manylinux1_x86_64.whl
Building wheels requires:
- CMake
- Git
- C++ Compiler - Platform specific requirements are summarized in scikit-build documentation.
- Python
Build the SimpleITK Python wheel with the following command:
mkvirtualenv build-sitk
pip install -r requirements-dev.txt
python setup.py bdist_wheel
The Python build package should be used to build the source distribution:
python -m build --sdist
If on a given platform you would like to build wheels for different version of python, you can build the SimpleITK core libraries first and reuse them when building each wheel.
Here are the steps:
-
Build
SimpleITKPythonPackage
withSimpleITKPythonPackage_BUILD_PYTHON
set toOFF
-
Build "flavor" of package using:
python setup.py bdist_wheel -- \
-DSimpleITK_DIR:PATH=/path/to/SimpleITKPythonPackage-core-build/SimpleITK-superbuild/SimpleITK-build \
-DSWIG_EXECUTABLE:PATH=/path/to/SimpleITKPythonPackage-core-build/SimpleITK-superbuild/Swig/bin/swig
Written by Jean-Christophe Fillion-Robin from Kitware Inc.
It is covered by the Apache License, Version 2.0:
http://www.apache.org/licenses/LICENSE-2.0
For more information about SimpleITK, visit http://simpleitk.org
For more information about ITK, visit http://itk.org