Qt (python) snap crashes on load or save with apparmor denials

(I have to be very delivery-oriented, and to the right market, as I am “low on numbers”. The Linux market showed no signs of life - Win & Mac seem better (sniff) - while there’s been a significant amount of hurdles and productivity loss from my perspective with deploying my project, even in relation to snapping - possibly my bad … so I kept the step yielding my zipped PyInstaller results separate, in case I’d have to back off to only delivering to recent LTS Ubuntus as earlier planned. Now I am only packaging one of those with snapcraft as I treat the Snap Store as a desired distribution platform, not sure if for any other reason.

Payload information for you perhaps too: multipass may not be an absolute requirement, snapcraft --destructive-mode should allow e.g. me to get around the nested-virtualization caveat I ran into earlier with my (then VM) build U18 + VirtualBox + snapcraft, also allow for a saner build process, where I’ll likely be able to inspect/debug etc. a relevant final product experience in a more usual way pre snapping.

But I do hope you guys get things sorted the proper way and I’ll have the honor of peeking into some serious system level debugging on Linux nevertheless!)

Tried this and now I get this:

    self.splitter = QSplitter(Qt.Vertical, self)
NameError: name 'Qt' is not defined
python3: relocation error: /snap/tablexplore/x1/lib/python3.6/site-packages/PySide2/Qt/plugins/imageformats/libqicns.so: symbol _ZdlPvm version Qt_5 not defined in file libQt5Core.so.5 with link time reference

Okay. It looks like using the binary PySide2 wheel from pypi will not work with the Qt 5 libraries from the kde-neon extension. I’m kind of surprised that PySide would be expecting Qt to provide that particular symbol:

$ echo _ZdlPvm | c++filt
operator delete(void*, unsigned long)

On modern Linux systems (at least as far back as Ubuntu 16.04), that symbol is provided by libstdc++ so a Qt built in that environment won’t include it. As the Qt included with PySide2 exports it with the “Qt_5” symbol version though, the Python extension won’t use the version provided by libstdc++.

Realistically, there are two options here:

  1. Stop using the kde-neon extension and depend entirely on the Qt distributed with the PyPI version of PySide2. This would mean redoing all the integration work the extension handles for you.

  2. Use a version of PySide2 compiled against Ubuntu 18.04’s Qt binaries.

For (2), that probably means building PySide2 from source as a second part in your Snapcraft recipe, since there are no deb packages of PySide2 in the 18.04 repository that you could reference via stage-packages. It is in the 20.04 repository, but the kde-neon extension does not yet support core20 snaps :frowning:

There are packages of PyQt5 in 18.04 though (as python3-pyqt5), which is mostly compatible with PySide2. Note that it comes under a different license though, so might not be appropriate on those grounds.

1 Like

I think the easiest thing is to enable the application to use PyQt5 when it’s present as they are basically interchangeable. I can then use the deb package and ignore the PySide2 package from pip. Is there a directive to omit dependencies that are in the setup.py file?

I can confirm that this now works when PyQt5 is used instead. I just remove the PySide2 dependency from setup.py temporarily when building so it will not be included in the snap.

I use these imports to allow using either library:

try:
    from PySide2 import QtCore
    from PySide2.QtWidgets import *
    from PySide2.QtGui import *
    from PySide2.QtCore import QObject, Signal, Slot
except:
    from PyQt5 import QtCore
    from PyQt5.QtWidgets import *
    from PyQt5.QtGui import *
    from PyQt5.QtCore import pyqtSignal as Signal, pyqtSlot as Slot
2 Likes