[ITK-users] ITKModuleTemplate and external modules for use with python

<[email protected]> Thu, 12 Jul 2018 11:36:06 +0000
Newsgroups gmane.comp.lib.itk.user
Message-ID <[email protected]>
--===============1881857171==
Content-Language: en-US
Content-Type: multipart/alternative;
	boundary="_000_45eec90025e2442c85429ef978da1ecdexch3melnexuscsiroau_"

--_000_45eec90025e2442c85429ef978da1ecdexch3melnexuscsiroau_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi All,

I'm revisiting making my own external ITK module (for use in Python) after =
an initial attempt a while back. This time I've managed to get much further=
 and have managed to successfully create python wheels following the direct=
ions on https://github.com/InsightSoftwareConsortium/ITKPythonPackage/blob/=
master/docs/Build_ITK_Module_Python_packages.rst  , I've created Windows wh=
eels via AppVeyor and linux wheels with CircleCI in addition to locally bui=
lt versions via the docker based method. All tests are passed successfully.

However, after installing them with pip in a fresh virtual environment in a=
 Python 3.6 instance (Anaconda), I seem to always get a kernel crash (segme=
ntation fault) when I try and actually use or create one of my custom filte=
rs.

To strip everything back to basics I generated a vanilla external module, u=
sing only default values with:

python -m cookiecutter gh:InsightSoftwareConsortium/ITKModuleTemplate

I then built the wheels as described and installed them into the virtual en=
vironment.

Using the following basic python script below results in a seg fault,

import itk
InputType =3D itk.Image[itk.F,2]
OutputType =3D itk.Image[itk.F,2]
test =3D itk.MinimalStandardRandomVariateGenerator.New()

I get the same result if I try and create any of the classes defined in ITK=
ModuleTemplate, however I can successfully create standard itk filters.

After running the script with gdb I see that it crashes in the call as foll=
ows:

#1  0x00007fffe7405373 in PyInit__ModuleTemplatePython () from /home/tho78s=
/anaconda3/lib/python3.6/site-packages/itk/Configuration/../_ModuleTemplate=
Python.so

I'm currently out of ideas as to where the problem lies and I seem to get t=
he identical problem in Windows too.

Any help or pointers in to what is going wrong would be greatly appreciated=
!

I you want any extra info, feel free to contact me.

Regards,

Darren


--_000_45eec90025e2442c85429ef978da1ecdexch3melnexuscsiroau_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;
	mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:#0563C1;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:#954F72;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	mso-fareast-language:EN-US;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-AU" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">Hi All,<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">I&#8217;m revisiting making my own external ITK modu=
le (for use in Python) after an initial attempt a while back. This time I&#=
8217;ve managed to get much further and have managed to successfully create=
 python wheels following the directions on
<a href=3D"https://github.com/InsightSoftwareConsortium/ITKPythonPackage/bl=
ob/master/docs/Build_ITK_Module_Python_packages.rst">
https://github.com/InsightSoftwareConsortium/ITKPythonPackage/blob/master/d=
ocs/Build_ITK_Module_Python_packages.rst</a> &nbsp;, I&#8217;ve created Win=
dows wheels via AppVeyor and linux wheels with CircleCI in addition to loca=
lly built versions via the docker based method.
 All tests are passed successfully.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">However, after installing them with pip in a fresh v=
irtual environment in a Python 3.6 instance (Anaconda), I seem to always ge=
t a kernel crash (segmentation fault) when I try and actually use or create=
 one of my custom filters.
<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">To strip everything back to basics I generated a van=
illa external module, using only default values with:
<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">python -m cookiecutter gh:InsightSoftwareConsortium/=
ITKModuleTemplate<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">I then built the wheels as described and installed t=
hem into the virtual environment.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Using the following basic python script below result=
s in a seg fault,
<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-family:&quot;Courier New&quot;">=
import itk<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-family:&quot;Courier New&quot;">=
InputType =3D itk.Image[itk.F,2]<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-family:&quot;Courier New&quot;">=
OutputType =3D itk.Image[itk.F,2]<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-family:&quot;Courier New&quot;">=
test =3D itk.MinimalStandardRandomVariateGenerator.New()
<o:p></o:p></span></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">I get the same result if I try and create any of the=
 classes defined in ITKModuleTemplate, however I can successfully create st=
andard itk filters.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">After running the script with gdb I see that it cras=
hes in the call as follows:<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-family:&quot;Courier New&quot;">=
#1&nbsp; 0x00007fffe7405373 in PyInit__ModuleTemplatePython () from /home/t=
ho78s/anaconda3/lib/python3.6/site-packages/itk/Configuration/../_ModuleTem=
platePython.so<o:p></o:p></span></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">I&#8217;m currently out of ideas as to where the pro=
blem lies and I seem to get the identical problem in Windows too.<o:p></o:p=
></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Any help or pointers in to what is going wrong would=
 be greatly appreciated!<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">I you want any extra info, feel free to contact me.<=
o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Regards,<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Darren<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</body>
</html>

--_000_45eec90025e2442c85429ef978da1ecdexch3melnexuscsiroau_--

--===============1881857171==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
https://itk.org/mailman/listinfo/insight-users

--===============1881857171==--