Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-511

"PythonInterp" and "PythonLibs" CMake Modules Discovered in Wrong Order

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Done
    • Affects Version/s: 5.6, dev
    • Fix Version/s: 5.6
    • Component/s: PySide
    • Labels:
      None
    • Environment:
      Qt: 5.6; Python: 2.7, 3.4; OS: Gentoo Linux
    • Commits:
      a3027cc4e5cc30663f700284b0dc6a19640ccca7

      Description

      This one's a quicky. Promise.

      PySide2's CMakeLists.txt finds the PythonInterp and PythonLibs packages in the wrong order. Ideally, the former should be found first and the latter second. Why? Because PythonInterp sets global CMake variables accessed by PythonLibs. Finding these packages in the wrong order invites desynchronization between the executable, library, and include paths of the Python interpreter to be built against.

      As commented in /usr/share/cmake/Modules/FindPythonLibs.cmake:

      # If calling both ``find_package(PythonInterp)`` and
      # ``find_package(PythonLibs)``, call ``find_package(PythonInterp)`` first to
      # get the currently active Python version by default with a consistent version
      # of PYTHON_LIBRARIES.
      

      Shiboken2 does it oh-so-right:

      if (USE_PYTHON_VERSION)
          find_package(PythonInterp ${USE_PYTHON_VERSION} REQUIRED)
          find_package(PythonLibs ${USE_PYTHON_VERSION} REQUIRED)
      else()
          find_package(PythonInterp 2.6)
          find_package(PythonLibs 2.6)
      endif()
      

      PySide2 does it not-so-right:

      if (USE_PYTHON_VERSION)
          find_package(PythonLibs ${USE_PYTHON_VERSION} REQUIRED)
          find_package(PythonInterp ${USE_PYTHON_VERSION} REQUIRED)
      else()
          find_package(PythonLibs 2.6)
          find_package(PythonInterp 2.6)
      endif()
      

      Fortunately, the fix is trivial. And that's something we can all drink to.

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            ctismer Christian Tismer
            Reporter:
            leycec Cecil Curry
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes