Fix loading of the Python library
ClosedPublic

Authored by pino on May 27 2018, 8:39 AM.

Details

Summary

Instead of assuming the unversioned .so symlink will exist also at
runtime (which is not the case for binary distros), use the QLibrary
features: the SONAME of the Python library is "1.0", so use the
unsuffixed filename of Python library with it.

Additionally, this extends the loading also to Unices platforms
different than macOS (since Boud excluded it in a previous commit),
and destroy the QLibrary in case of loading failure.

BUG: 393307
Fixed-In: 4.0.4

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.
pino requested review of this revision.May 27 2018, 8:39 AM
pino created this revision.
rempt added a subscriber: rempt.May 29 2018, 7:00 AM

Um... This only applies to the krita/4.0, doesn't it? And doesn't removing the else block break the case where the library isn't anymore in the location where cmake found it?

pino added a comment.May 29 2018, 7:09 AM

This only applies to the krita/4.0, doesn't it?

Ahh yes... I thought fixes would be to stable branches, and then merged to master. I can rebase it to master in the next version.

And doesn't removing the else block break the case where the library isn't anymore in the location where cmake found it?

If the library name is a simple file name (i.e. not a full path), QLibrary does a search in the library paths. This was the case I wanted to fix, i.e. libpythonX.Yetc.so present at build time (and stored in the PYKRITA_PYTHON_LIBRARY define), but not present at runtime (where only the libpythonX.Yetc.so.1.0 is available); this is typically the case of binary distros that split library/devel stuff, such as Debian, Fedora, *SUSE, and their derived.

rempt accepted this revision.May 29 2018, 7:40 AM

We usually go from master to the stable branch, which I know isn't the recommended flow, but it's what we do... I guess that this patch should be fine then, because the appimage sets the library paths. It might even fix loading python in a macOS app bundle, because that had the same problems as the appimage.

This revision is now accepted and ready to land.May 29 2018, 7:40 AM
pino updated this revision to Diff 35080.May 29 2018, 7:49 AM

Rebased on master.

rempt added a comment.May 29 2018, 8:28 AM

Okay, I tested this with master, please push.

This revision was automatically updated to reflect the committed changes.
pino added a comment.May 29 2018, 8:47 AM

Done, should I backport it to krita/4.0 as well?

rempt added a comment.May 29 2018, 9:01 AM

Yes, please.