Page MenuHomePhabricator

Improve Python 3 integration
Closed, ResolvedPublic


  • Python isn't an external project anymore but it is handled like one with hard-coded exceptions
  • The find_package() call is split into multiple calls which is explicitly discouraged in the CMake documentation
  • It's still MITK_USE_Python but as MITK_USE_ variables are handled specially, it should match the actual name Python3
  • A PackageDepends Config file is missing
  • Package dependencies in modules are still using the old PythonLibs
  • Python Wrapping is still based on PythonLibs

Event Timeline

kislinsk triaged this task as Normal priority.Aug 2 2019, 5:34 PM
kislinsk created this task.

Bug(s) in CTK:

find_package(PythonLibs) is called multiple times without checking for PYTHONLIBS_FOUND first. If it was already found, PYTHON_LIBRARY potentially is a list of the form "optimized;python3.lib;debug;python3d.lib" instead of just "python3.lib". The FindPythonLibs module can't handle this list and produces something like "optimized;optimized;optimized;python3.lib;debug;debug;debug;python3d.lib". The list (doesn't matter if corrupted or not) is then passed down to PythonQt as PYTHON_LIBRARY. However, providing PYTHON_LIBRARY as a hint to the FindPythonLibs module should be in non-list format of the release library.

In ctkMacroCompilePythonScript.cmake there's a call like get_filename_component(PYTHON_LIBRARY_PATH ${PYTHON_LIBRARY} PATH). ${PYTHON_LIBRARY} should be quoted to support white spaces in the path and it also cannot handle the list format.

Just a comment. Python wrapping is handled independently. We should talk to Michel about this.

Prepared fix for CTK:

Will test with Linux and macOS before creating a pull request.

It's MITK_USE_Python3 now instead of MITK_USE_Python. On macOS CMAKE_FRAMEWORK_PATH can be used to hint our CMake script to find a specific version of Python as Python 3.7 does not work at the moment.

neher added a project: MITK Diffusion.

Missed it. "improve python 3 integration", "migrate to improved python 3 integration". Potato, Potahto