# Proposal: Install SimpleITK from wheels instead of building from source

**URL:** https://discourse.slicer.org/t/proposal-install-simpleitk-from-wheels-instead-of-building-from-source/25635
**Category:** Development
**Tags:** python
**Created:** [October 11, 2022, 4:31am UTC](https://discourse.slicer.org/t/proposal-install-simpleitk-from-wheels-instead-of-building-from-source/25635 "2022-10-11T04:31:17Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)
#### Post date: [October 11, 2022, 4:31am UTC](https://discourse.slicer.org/t/proposal-install-simpleitk-from-wheels-instead-of-building-from-source/25635/1 "2022-10-11T04:31:17Z")

</div>

Now that Slicer [PR-6564](https://github.com/Slicer/Slicer/pull/6564) adding support for building ITK with a custom namespace has been integrated, installing SimpleITK from wheels should be possible.

Pros:

1. Reduced build time by a factor x2 (and probably more on windows)
2. Version of SimpleITK bundled in Slicer may be update-able using `pip`, this would allow to install a newer SimpleITK in a released Slicer distribution.
3. Reduced build-system complexity by removing external projects `Swig`, `PCRE` and `SimpleITK` and introducing `python-SimpleITK`

Cons:

1. Fixes integrated in ITK C++ that is used to build Slicer may not be immediately be available in the nightly build, they may only be available once new SimpleITK wheels are released.

## Questions

Assuming SimpleITK wheels can be used, should we move forward with this proposal ?

Should we distribute [SimpleFilters](https://github.com/SimpleITK/SlicerSimpleFilters) as a standalone extension and further reduce the size of the main Slicer package ?

- `_SimpleITK.cpython-39-x86_64-linux-gnu.so` is `259M` on Linux
- `_SimpleITK.cpython-39-darwin.so` is `201M` on macOS
- `_SimpleITK.cp39-win_amd64.pyd` is `10M` on Windows

Rational for smaller library on Windows:

> ```auto
> # SimpleITK has large internal libraries, which take an extremely long
> # time to link on windows when they are static. Creating shared
> # SimpleITK internal libraries can reduce linking time. Also the size
> # of the debug libraries are monstrous. Using shared libraries for
> # debug, reduce disc requirements, and can improve linking
> # times. However, these shared libraries take longer to load than the
> # monolithic target from static libraries.
> 
> ```

_Source: [Slicer@ff8f546e4](https://github.com/Slicer/Slicer/commit/ff8f546e4d88db793f8d8a8973625a0c6da91598) (COMP: Adding option for SimpleITK as a shared library)_

## Preliminary testing

After removing `ITK_AUTOLOAD_PATH` from the environment, the SimpleITK package could successfully be installed & imported on Linux (Ubuntu 20.04.4).

```python
import os
del os.environ["ITK_AUTOLOAD_PATH"]
import SimpleITK

```

That said, attempting to apply a filter by leveraging the `SlicerSimpleFilter` module failed with the following error:

```python
Exception thrown in SimpleITK ImageFileReader_Execute: /tmp/SimpleITK/Code/IO/src/sitkImageReaderBase.cxx:97:

sitk::ERROR: The file "slicer:0x561741d91310#vtkMRMLScalarVolumeNode1" does not exist.

```

This means that we should revisit how the `SlicerSimpleFilter` module access volume node information by instead passing numpy array by leveraging `vtk.util.numpy_support` like what is done in [itk.vtk\_image\_from\_image/itk.image\_from\_vtk\_image](https://github.com/InsightSoftwareConsortium/ITK/blob/4fd5ea0005e81a473eb12460e607ba76f0e382e1/Wrapping/Generators/Python/itk/support/extras.py#L626-L727) or [sitk2vtk.py](https://github.com/dave3d/dicom2stl/blob/main/utils/sitk2vtk.py)/[vtk2sitk.py](https://github.com/dave3d/dicom2stl/blob/main/utils/vtk2sitk.py)

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [October 19, 2022, 6:20am UTC](https://discourse.slicer.org/t/proposal-install-simpleitk-from-wheels-instead-of-building-from-source/25635/2 "2022-10-19T06:20:47Z")

</div>

> [@jcfr](#):
>
> Assuming SimpleITK wheels can be used, should we move forward with this proposal ?

Yes! (due to the reasons you described above)

> [@jcfr](#):
>
> Should we distribute [SimpleFilters](https://github.com/SimpleITK/SlicerSimpleFilters) as a standalone extension and further reduce the size of the main Slicer package ?

Yes, because reducing the installer size (and maybe reducing startup time?) would be very useful. Especially because ITKPython wrapping is kept being improved so developers may choose to use that instead of SimpleITK. For extensions in Slicer-5.3 and later we could add SimpleITK extension as a dependency if the extension uses SimpleITK.

---

<div class="post-metadata">

### Author: ![blowekamp](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/blowekamp/32/1386_2.png) [@blowekamp](https://discourse.slicer.org/u/blowekamp)
#### Post date: [October 21, 2022, 12:43pm UTC](https://discourse.slicer.org/t/proposal-install-simpleitk-from-wheels-instead-of-building-from-source/25635/3 "2022-10-21T12:43:03Z")

</div>

> [@jcfr](#):
>
> 1. Fixes integrated in ITK C++ that is used to build Slicer may not be immediately be available in the nightly build, they may only be available once new SimpleITK wheels are released.

SimpleITK rebuild builds packages for most of the common wheels each night when there has been a source code change in the master branch. Currently these are just uploaded to Github for the “latest” release, and discarded when the next latest package is created. Discussions have occurred if it would be useful to upload these packages to an S3 bucket or some other place to be archived for some period ( total size / time limit ). This could enabled fixes and contributions to SimpleITK to be readily available to the Slicer community.

---

<div class="post-metadata">

### Author: ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)
#### Post date: [January 13, 2023, 4:07am UTC](https://discourse.slicer.org/t/proposal-install-simpleitk-from-wheels-instead-of-building-from-source/25635/4 "2023-01-13T04:07:07Z")

</div>

Things have observed to break down when Slicer’s SimpleITK is uninstalled a SimpleITK upstream version is installed from whl. [Slicer's embedded SimpleITK can be removed by pip · Issue #6711 · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/issues/6711)

As of right now it seems that proceeding with using SimpleITK whl files is not possible within Slicer due to requiring the fixes made in [BUG: Update SimpleITK to fix test\_sitkUtils by jcfr · Pull Request #6606 · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/pull/6606) which are not in SimpleITK upstream.

---

<div class="post-metadata">

### Author: ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)
#### Post date: [December 26, 2025, 10:51pm UTC](https://discourse.slicer.org/t/proposal-install-simpleitk-from-wheels-instead-of-building-from-source/25635/5 "2025-12-26T22:51:55Z")

</div>

This proposal has been completed with the integration of the following commits:

> <https://github.com/Slicer/Slicer/commit/3c72591d38fa22e8496864eed6805e8e7dcf08db>
>
> This updates PullVolumeFromSlicer and PushVolumeToSlicer to utilize the vtk2sitk… and sitk2vtk methods that do not rely on the existing custom SimpleITK for image conversion.

> <https://github.com/Slicer/Slicer/commit/f87c977465f3b63219456186b7673f5c12e8b514>
