Fix PyKrita library path when running from a built Krita in MacOS
ClosedPublic

Authored by lsegovia on Jun 22 2018, 4:47 PM.

Details

Summary

With the recent changes in PyKrita's lookup path (bool Python::setPath(const QStringList& scriptPaths)), it's impossible to start Krita without either of the following:

  • a ModuleNotFoundError for the 'encodings' module, followed by a SIG_ABRT crash
  • a ModuleNotFoundError for the 'sip' module, but Krita continues running.

The first happens because when runningInBundle, only Krita's library directories are preserved in the lookup path, thus breaking lookup of system package. The second is usually a consequence of attempting to fix the first by setting runningInBundle to false, and it happens because in the lookup path the site-packages folder isn't taken into account.

Fortunately, it is easy to fix this: by checking the result of findKritaPythonLibsPath on the Python dylib, and if it's not found in the app bundle, preserving the original lookup path as returned by Py_GetPath and adding the missing site-packages directories..

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.
lsegovia created this revision.Jun 22 2018, 4:47 PM
Restricted Application added a reviewer: Krita. · View Herald TranscriptJun 22 2018, 4:47 PM
lsegovia requested review of this revision.Jun 22 2018, 4:47 PM
rempt accepted this revision.Jun 24 2018, 11:03 AM
This revision is now accepted and ready to land.Jun 24 2018, 11:03 AM
This revision was automatically updated to reflect the committed changes.