Page MenuHomePhabricator | MITK

MITK make PACKAGE does not work on windows if Python is enabled
Closed, ResolvedPublic


It has been reported via the users list that the installer on windows does not correctly build if Python is activated. We might want to include the fix for T22591 as provided in D39 in this task as well.


Differential Revisions
Restricted Differential Revision

Event Timeline

goch triaged this task as Normal priority.
neher added a comment.Jan 25 2018, 4:05 PM

There is also an issue with macke package on linux if python is enabled. Apparently cpack cannot find libpythonqt.

Got the build working on windows up to and including the MITK build. There is a CTK change that I will contribute once I have verified Python works fine with MITK and python 3 and CTK still builds with python 2.

One remaining issue is with the python workbench in MITK. Responsible seems to be this line. Commenting it changes whether I can run any number of commands or I get exceptions in python after the first. Adding some debug output:

for(int i = 0; i<PyList_Size(dirMain); i++)
    tempObject = PyList_GetItem(dirMain, i);
    name = PyString_AsString(tempObject);
    tempObject = PyObject_GetAttrString( object, name.c_str() );
    attrType = tempObject->ob_type->tp_name;

    if (strTempObject)
      MITK_INFO << "    Before: " << name;
      MITK_INFO << "    Before: " << "Invalid pointer " << name;
    strTempObject = PyObject_Repr(tempObject);
      MITK_INFO << "    After: " << PyString_AsString(strTempObject);
      MITK_INFO << "    After: " << "Invalid pointer";
    //if(strTempObject && ( PyUnicode_Check(strTempObject) || PyString_Check(strTempObject) ) )
    //  attrValue = PyString_AsString(strTempObject);
    //  attrValue = "";

    mitk::PythonVariable var;
    var.m_Name = name;
    //var.m_Value = attrValue;
    var.m_Type = attrType;

    MITK_INFO << "Temp: " << name << " Type: " << attrType << " Value: " << attrValue << " Size:" << PyList_Size(dirMain);

I get the output

172.87 core.mod.python.ctkpythonshell: executing command print(3)
172.88 core.mod.python.svc: pythonCommand = print(3)
172.88 core.mod.python.svc: commandType = 1
172.88 core.mod.python.svc: Getting Variable Stack from service
172.89 core.mod.python.svc: The one above
172.89 core.mod.python.svc:   dict: dictValue: 000000F9B8F37048
172.90 core.mod.python.svc:   object: moduleValue: 000000F9B8FB47C8
172.91 core.mod.python.svc:   dirMain: listValue: 000000F9BA407D88
172.91 core.mod.python.svc: Should have the same number as above and below
172.92 core.mod.python.svc:   dict: dictValue: 000000F9B8F37048
172.93 core.mod.python.svc:   object: moduleValue: 000000F9B8FB47C8
172.93 core.mod.python.svc:   dirMain: listValue: 000000F9BA404708
172.94 core.mod.python.svc:     Before: Invalid pointer __annotations__
172.95 core.mod.python.svc:     After: {}
172.95 core.mod.python.svc: Temp: __annotations__ Type: dict Value:  Size:12
172.96 core.mod.python.svc:     Before: __builtins__
172.96 core.mod.python.svc:     After: <module 'builtins' (built-in)>
172.97 core.mod.python.svc: Temp: __builtins__ Type: module Value:  Size:12
172.98 core.mod.python.svc:     Before: __ctkConsole
172.98 core.mod.python.svc:     After: <code.InteractiveConsole object at 0x000000F9B9294470>
172.99 core.mod.python.svc: Temp: __ctkConsole Type: InteractiveConsole Value:  Size:12
173.00 core.mod.python.svc:     Before: __doc__
173.00 core.mod.python.svc:     After: None
173.01 core.mod.python.svc: Temp: __doc__ Type: NoneType Value:  Size:12
173.01 core.mod.python.svc:     Before: __loader__
173.02 core.mod.python.svc:     After: <class '_frozen_importlib.BuiltinImporter'>
173.03 core.mod.python.svc: Temp: __loader__ Type: type Value:  Size:12
173.03 core.mod.python.svc:     Before: __name__
173.04 core.mod.python.svc:     After: '__main__'
173.04 core.mod.python.svc: Temp: __name__ Type: str Value:  Size:12
173.05 core.mod.python.svc:     Before: __package__
173.05 core.mod.python.svc:     After: None
173.06 core.mod.python.svc: Temp: __package__ Type: NoneType Value:  Size:12
173.06 core.mod.python.svc:     Before: __spec__
173.07 core.mod.python.svc:     After: None
173.07 core.mod.python.svc: Temp: __spec__ Type: NoneType Value:  Size:12
173.08 core.mod.python.svc:     Before: code
173.08 core.mod.python.svc:     After: <module 'code' from 'D:\\tools\\Python3.6.3\\Lib\\'>
173.09 core.mod.python.svc: Temp: code Type: module Value:  Size:12
173.10 core.mod.python.svc:     Before: help
173.11 core.mod.python.svc:     After: Invalid pointer
173.11 core.mod.python.svc: Temp: help Type: Helper Value:  Size:12
173.12 core.mod.python.svc:     Before: Invalid pointer site
173.13 core.mod.python.svc:     After: Invalid pointer
173.13 core.mod.python.svc: Temp: site Type: module Value:  Size:12
173.14 core.mod.python.svc:     Before: Invalid pointer sys
173.14 core.mod.python.svc:     After: Invalid pointer
173.15 core.mod.python.svc: Temp: sys Type: module Value:  Size:12
173.16 core.mod.python.svc: The one below
173.16 core.mod.python.svc:   dict: dictValue: 000000F9B8F37048
173.17 core.mod.python.svc:   object: moduleValue: 000000F9B8FB47C8
173.17 core.mod.python.svc: Variable stack pre-execution size = 12
173.19 core.mod.python.svc: Getting Variable Stack from service
173.19 core.mod.python.svc: The one above
173.19 core.mod.python.svc:   dict: dictValue: 000000F9B8F37048
173.20 core.mod.python.svc:   object: moduleValue: 000000F9B8FB47C8
173.20 core.mod.python.svc: Should have the same number as above and below
173.21 core.mod.python.svc:   dict: dictValue: 000000F9B8F37048
173.21 core.mod.python.svc:   object: moduleValue: 000000F9B8FB47C8
173.22 core.mod.python.svc: The one below
173.22 core.mod.python.svc:   dict: dictValue: 000000F9B8F37048
173.23 core.mod.python.svc:   object: moduleValue: 000000F9B8FB47C8
173.23 core.mod.python.svc: Variable stack pre-execution size the second = 0
Traceback (most recent call last):
  File "D:\tools\Python3.6.3\Lib\", line 1849, in __repr__
    if inspect.stack()[1][3] == '?':
IndexError: list index out of range

A pull request has been opened with CTK to include the changes necessary to support our switch to python3

The change to the python use, sytem instead of setup, might require us adding a redistributable/installer to the MITK installer.

goch added a revision: Restricted Differential Revision.Apr 23 2018, 4:07 PM
neher claimed this task.Jun 29 2018, 12:50 PM
neher closed this task as Resolved.Jul 7 2018, 4:25 PM