# Build errors : ITK Module Python Wrapping

**URL:** https://discourse.itk.org/t/build-errors-itk-module-python-wrapping/853
**Category:** Engineering
**Tags:** python, module, cmake
**Created:** [April 19, 2018, 10:47am UTC](https://discourse.itk.org/t/build-errors-itk-module-python-wrapping/853 "2018-04-19T10:47:39Z")
**Posts on this page:** 7
**Page:** 2

<div class="post-metadata">

### Author: ![T4mmi](https://discourse.itk.org/user_avatar/discourse.itk.org/t4mmi/32/311_2.png) [@T4mmi](https://discourse.itk.org/u/T4mmi)
#### Post date: [May 15, 2018, 4:02pm UTC](https://discourse.itk.org/t/build-errors-itk-module-python-wrapping/853/21 "2018-05-15T16:02:06Z")

</div>

Ok, summary of the day :

**Windows 7 / Python 3.5 (miniconda) / ITK 4.12 (conda-forge)** - OK  
**Windows 7 / Python 3.5 (miniconda) / ITK 4.13 (conda-forge)** - OK  
**Windows 7 / Python 3.5 (miniconda) / ITK 5.0 (conda-forge)** - OK

**Ubunutu 18.04 / Python 3.6 (anaconda) / ITK 4.13 (conda-forge)** - OK

**macOS 10.13.3 / Python 3.5 (anaconda) / ITK 4.13 (conda-forge)** - `Bus error: 10`  
**macOS 10.13.3 / Python 3.6 (anaconda) / ITK 4.13 (conda-forge)** - `Floating point exception: 8`

… seems like the macOS wrapping is not working …

_**[edit]** I also tried using native Python installations (without conda) and various ITK version (4.12, 4.13, 5.0) … all ended with errors under macOS while everything seems to work perfectly with Windows/Linux_

_\_\_[edit 2]\_\_I used macOS 10.13_

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [May 25, 2018, 9:53pm UTC](https://discourse.itk.org/t/build-errors-itk-module-python-wrapping/853/22 "2018-05-25T21:53:51Z")

</div>

Outstanding investigation @T4mmi !

I will try to reproduce…

---

<div class="post-metadata">

### Author: ![T4mmi](https://discourse.itk.org/user_avatar/discourse.itk.org/t4mmi/32/311_2.png) [@T4mmi](https://discourse.itk.org/u/T4mmi)
#### Post date: [June 1, 2018, 1:55pm UTC](https://discourse.itk.org/t/build-errors-itk-module-python-wrapping/853/23 "2018-06-01T13:55:29Z")

</div>

Could not find the reason why it doesn’t work on mac …  
I do suspect a problem with travis build but to be fair I did not investigate further.

Last ‘problem’ that I’m facing that you may help with concerns the versionning / dependencies requirements. Since I’ve build the module for both ITK 4 & 5, I would like to distribute them through PyPI. I created two versions (4.x and 5.x, one from each branch - yes bad naming of the versions) but `pip install` fails with `ITK 4.13`, I do have to force `pip install module==4.x` …  
Does it come from the version numbering ? is there a ‘standard’ way to do this without forcing the upgrade to `ITK v5` ?

_if someone have an answer it might be a good addition to the [external module tuto](https://discourse.itk.org/t/itk-external-module-github-builds-for-4-x-and-5-x/900)_

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [June 6, 2018, 6:01pm UTC](https://discourse.itk.org/t/build-errors-itk-module-python-wrapping/853/24 "2018-06-06T18:01:41Z")

</div>

I tried to reproduce locally, but I could not reproduce the segfault with a `Debug` or `Release` build. @T4mmi Do you observe the segfault with local builds, the TravisCI package, or both?

Inspecting the code, these lines

> <https://github.com/T4mmi/ITKBinaryThinning3D/blob/14042da1ad1b40b8bf959093fb540334ebfbf836/include/itkBinaryThinningImageFilter3D.h#L61>

needs to be changed to:

```auto
template <class TInputImage, class TOutputImage>
class ITK_TEMPLATE_EXPORT BinaryThinningImageFilter3D : public ImageToImageFilter<TInputImage, TOutputImage>

```

The `ITK_TEMPLATE_EXPORT` is required for correct symbol exports on macOS. It is likely that a missing `ITK_TEMPLATE_EXPORT` somewhere causes the segfaults that are observed.

> [@T4mmi](#):
>
> Last ‘problem’ that I’m facing that you may help with concerns the versionning / dependencies requirements. Since I’ve build the module for both ITK 4 & 5, I would like to distribute them through PyPI. I created two versions (4.x and 5.x, one from each branch - yes bad naming of the versions) but pip install fails with ITK 4.13, I do have to force pip install module==4.x …
> 
> Does it come from the version numbering ? is there a ‘standard’ way to do this without forcing the upgrade to ITK v5 ?
> 
> if someone have an answer it might be a good addition to the external module tuto

Good question and suggestion. I added the following to the external module tutorial:

> - On the 5.X development branch, set the `version=` value in `setup.py` to a [pre-release version](https://www.python.org/dev/peps/pep-0440/#pre-releases), i.e. `X.YaN`, `X.YbN`, or `X.YrcN` where `X.Y` are higher numbers than the versions on the 4.X branch. This will ensure that a user can install the 4.X-based package with `pip install itk-mymodule` or the 5.X-based package with `pip install --pre itk-mymodule`.

Please let me know if that is unclear or can be improved.

---

<div class="post-metadata">

### Author: ![T4mmi](https://discourse.itk.org/user_avatar/discourse.itk.org/t4mmi/32/311_2.png) [@T4mmi](https://discourse.itk.org/u/T4mmi)
#### Post date: [June 7, 2018, 8:10am UTC](https://discourse.itk.org/t/build-errors-itk-module-python-wrapping/853/25 "2018-06-07T08:10:21Z")

</div>

> I tried to reproduce locally, but I could not reproduce the segfault with a Debug or Release build.

I would say good news then ! The problem might come from my setup (sorry for the issues) …

> @T4mmi Do you observe the segfault with local builds, the TravisCI package, or both?

I observe it using the TravisCI package (directly and through PyPI) since I did not compile locally the module (I should try it).

> The ITK\_TEMPLATE\_EXPORT is required for correct symbol exports on macOS. It is likely that a missing ITK\_TEMPLATE\_EXPORT somewhere causes the segfaults that are observed.

Ok, thanks I’ll change that ! ( it’s always good to learn 🙂 )

> On the 5.X development branch, set the version= value in setup.py to a pre-release version, i.e. X.YaN, X.YbN, or X.YrcN where X.Y are higher numbers than the versions on the 4.X branch. This will ensure that a user can install the 4.X-based package with pip install itk-mymodule or the 5.X-based package with pip install --pre itk-mymodule.

> Please let me know if that is unclear or can be improved.

That’s perfect !  
I didn’t know for the letters that were considered as pre-release version…

**Thanks again for your help during this first ITK wrapping**  
I’ll try to port some of our algorithms to ITK and provide Python modules for wider use.

---

<div class="post-metadata">

### Author: ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)
#### Post date: [June 7, 2018, 3:53pm UTC](https://discourse.itk.org/t/build-errors-itk-module-python-wrapping/853/26 "2018-06-07T15:53:23Z")

</div>

> [@T4mmi](#):
>
> Thanks again for your help during this first ITK wrapping
> 
> I’ll try to port some of our algorithms to ITK and provide Python modules for wider use.

That is fantastic! Please let use know if we can help!

Does adding `ITK_TEMPLATE_EXPORT` to _itkBinaryThinningImageFilter3D.h_ help with the macOS package segfaults?

---

<div class="post-metadata">

### Author: ![T4mmi](https://discourse.itk.org/user_avatar/discourse.itk.org/t4mmi/32/311_2.png) [@T4mmi](https://discourse.itk.org/u/T4mmi)
#### Post date: [June 8, 2018, 1:54pm UTC](https://discourse.itk.org/t/build-errors-itk-module-python-wrapping/853/27 "2018-06-08T13:54:26Z")

</div>

> Does adding ITK\_TEMPLATE\_EXPORT to itkBinaryThinningImageFilter3D.h help with the macOS package segfaults?

unfortunately nope, I should try on a different machine but I don’t have another mac (should mount a virtual one to test though) …

[Previous page](https://discourse.itk.org/t/build-errors-itk-module-python-wrapping/853.md?page=1)
