Build errors : ITK Module Python Wrapping

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

1 Like

Outstanding investigation @T4mmi !

I will try to reproduce…

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

1 Like

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

needs to be changed to:

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.

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, 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.

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 :slight_smile: )

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.

1 Like

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?

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) …

1 Like