SimpleITK / SlicerSimpleFilters

A Module for Slicer3D to provide a simple GUI to image filters from the Insight Toolkit.
Other
1 stars 12 forks source link

Python3 compatibility issues #17

Closed jamesobutler closed 5 years ago

jamesobutler commented 5 years ago

There are some compatibilities issues that were found by a user using the recent Slicer nightly which uses Python3.

https://discourse.slicer.org/t/simple-filters-module-do-not-have-any-filters-in-latest-nightly-version/6787

More issues might be present, but these were the first I have noticed.

blowekamp commented 5 years ago

Thank you for reporting the issue. Is this bug in the currently posted nightly build?

jamesobutler commented 5 years ago

Yes. Slicer nightly was download from slicer.org today as indicated by C:\Program Files\Slicer 4.11.0-2019-05-13 in the errors above.

blowekamp commented 5 years ago

It looks like Python3 may not be as forgiving with joining paths on windows with a mix of '\' and '/' slashes. I believe the issue is here on these lines: https://github.com/SimpleITK/SlicerSimpleFilters/blob/12efaabb0151c270e61bc7a3b3d08ad4c8db8095/SimpleFilters/SimpleFilters.py#L35-L36

and like would only present itself on windows. I would think changing:

ICON_DIR = os.path.dirname(os.path.realpath(__file__)) + '/Resources/Icons/'

to

ICON_DIR = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'Resources', 'Icons')
JSON_DIR = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'Resources, 'json')

Are you able to give that change a try?

jamesobutler commented 5 years ago

Changing https://github.com/SimpleITK/SlicerSimpleFilters/blob/12efaabb0151c270e61bc7a3b3d08ad4c8db8095/SimpleFilters/SimpleFilters.py#L105 to use open() fixes the initial error.

The second error is something related to these type of calls where "default" is now undefined in python3. Changing the joining of paths doesn't solve this issue. https://github.com/SimpleITK/SlicerSimpleFilters/blob/12efaabb0151c270e61bc7a3b3d08ad4c8db8095/SimpleFilters/SimpleFilters.py#L962-L963

blowekamp commented 5 years ago

nice job tracking done the file error!

jamesobutler commented 5 years ago

Closed by #19.