Fix loading PyKrita with PyQt 5.11
ClosedPublic

Authored by arojas on Jul 11 2018, 10:20 PM.

Details

Summary

PyQt>=5.11 uses its own private copy of SIP, with sipName PyQt5.sip. This causes an API mismatch with the Krita python module, which uses the default "sip" sipName, and the module fails to load. This patch fixes this by using the PyQt5.sip sipName for PyQt>=5.11

BUG: 396381

Test Plan

Python plugins work again with PyQt 5.11

Diff Detail

Repository
R37 Krita
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
arojas created this revision.Jul 11 2018, 10:20 PM
Restricted Application added a reviewer: Krita. · View Herald TranscriptJul 11 2018, 10:20 PM
Restricted Application added a project: Krita. · View Herald Transcript
arojas requested review of this revision.Jul 11 2018, 10:20 PM
rempt accepted this revision.Jul 12 2018, 8:55 AM

Thanks! Do you have push access, or should I push the patch for you?

This revision is now accepted and ready to land.Jul 12 2018, 8:55 AM

I do, just let me know what's the preferred merge workflow: push to 4.1 then merge to master or push to master and cherry-pick in 4.1?

rempt added a comment.Jul 12 2018, 9:00 AM

We usually do master, then cherry-pick to 4.1

This revision was automatically updated to reflect the committed changes.
rempt added a comment.Jul 13 2018, 8:00 AM

Eek, I tested this on Kubuntu, where it worked fine. On OpenSuse and on the nightly builds we get:

CMake Error at plugins/extensions/pykrita/sip/CMakeLists.txt:15 (if):

if given arguments:

  "050a01" "STRGREATER_EQUAL" "050b00"

Unknown arguments specified
  • Configuring incomplete, errors occurred!

Oh, STRGREATER_EQUAL requires cmake 3.7. If can be safely changed to STRGREATER, since PYQt 5.11.0 was withdrawn upstream so no distro shound be using it.

rempt added a comment.Jul 13 2018, 9:17 AM

Argh... I've changed the version check into VERSION_GREATER. and now it builds find on my local opensuse system, but the appimage builds are still broken:

https://binary-factory.kde.org/job/Krita_Nightly_Appimage_Build/157/consoleText
https://binary-factory.kde.org/job/Krita_Stable_Appimage_Build/57/consoleText

We are comparing string-formatted versions, so you should use STRGREATER, not VERSION_GREATER. Otherwise this will give unexpected results: on my system the if() evalulates to false even though I have PyQt 5.11, and in the appimage it seems to evaluate to TRUE with PyQt 5.9.

STRGREATER is available in cmake 2.8.12 which is Krita's required version, so it should be fine.

8ee0958ae632e49773b79f837daaf40305777d06 is still wrong: ${PYQT5_VERSION} is the alphanumeric version string, it can't be compared with 5.11.0. Either

if(${PYQT5_VERSION_STR} VERSION_GREATER 5.11.0)

or

if(${PYQT5_VERSION} STRGREATER "050b00")

should work (see cmake/modules/FindPyQt5.cmake)

Let's try if(${PYQT5_VERSION_STR} VERSION_GREATER 5.11.0) for now.

rempt added a comment.Jul 17 2018, 8:34 AM

Hm.... I've now moved to a laptop with the latest Neon and Qt 5.11, and now I get a build error:

[ 97%] Generating krita/sipkritapart0.cpp

sip: Unable to find file "QtCore/QtCoremod.sip"
plugins/extensions/pykrita/sip/CMakeFiles/python_module_PyKrita_krita.dir/build.make:93: recipe for target 'plugins/extensions/pykrita/sip/krita/sipkritapart0.cpp' failed
make[2]: * [plugins/extensions/pykrita/sip/krita/sipkritapart0.cpp] Error 1
make[2]:
* Deleting file 'plugins/extensions/pykrita/sip/krita/sipkritapart0.cpp'
CMakeFiles/Makefile2:29863: recipe for target 'plugins/extensions/pykrita/sip/CMakeFiles/python_module_PyKrita_krita.dir/all' failed
make[1]: * [plugins/extensions/pykrita/sip/CMakeFiles/python_module_PyKrita_krita.dir/all] Error 2
make[1]:
* Waiting for unfinished jobs....

No idea about this error (the location of the QtCore/QtCoremod.sip hasn't changed in 5.11 so it should be found as before, and in any case it should be unrelated to this patch).

However, I noticed that Debian has patched PyQt to revert upstream's decision of using a private sip:

https://salsa.debian.org/python-team/modules/pyqt5/commit/ecc66ca38179d0dbcb65212421dec11bc1e252e7

so Krita plugins loading will fail for them as it did for Arch before this patch. I personally don't understand upstream's decision and I think it makes things unnecessarily harder for packagers, but if every distro starts doing their own thing it will be a mess for downstream projects like Krita to support every possible scenario.

rempt added a comment.Jul 17 2018, 9:15 AM

Argh... I guess the only thing I can do now is add a manual override cmake flag.

Argh... I guess the only thing I can do now is add a manual override cmake flag.

There may be a way around it: it looks like PyQt5.Qt.PYQT_CONFIGURATION["sip_flags"] contains the sipname that was used to compile PyQt, so Krita should use that sipname for its bindings. I will try to write a patch.

rempt added a comment.Jul 17 2018, 9:20 AM

okay, that would be great.