Bundle a package from apt with a snap


I am currently trying to bundle my app DaKanji as a snap with snapcraft.
I am using python and PySide2 as GUI library.
However on Ubuntu 20.4 PySide2 does not run out of the box and

sudo apt-get install -y libxcb-xinerama0

needs to be invoked to make it run.
I am now wondering if it is possible to bundle this in the snap somehow.
I tried adding it to

    source: .
    plugin: python
    requirements: ['requirements.txt']
      - libxcb-xinerama0

This did not help and the app does not run as a snap.

I am also missing a lot of libraries which I am not sure how to add:
This part is missing libraries that cannot be satisfied with any available stage-packages known to snapcraft:

Maybe someone here can point me in the right direction.

Thanks in advance

I can’t specifically help you but when trying to find something that might I found this:

Since it’s python based, uses the library you are referencing it might be helpful.

1 Like

I tried to add the plugs used in this application however that also didn’t change the error message.

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Aborted (core dumped)

@futuretim Do you maybe know of any snap (with an available snapcraft.yaml) which uses pyside2?

how does your apps: section look like in your snapcraft.yaml (do you use any desktop-helper to set up a proper environment for Qt ?)

This is my complete snapcraft.yaml:

name: dakanji # you probably want to 'snapcraft register <name>'
base: core20 # the base snap is the execution environment for this snap
version: '1.2' # just for humans, typically '1.2+git' or '1.3.2'
summary: Draw a kanji with your mouse and open it in your dictionary of choice.
description: |
  Did you ever try to read a Japanese text but did not know how to read some Kanji? This app can help you with exactly that.
  Draw a Kanji and the app will convert it to a digital character.
  You can than open that character in a dictionary of your choice or use it somewhere else.

  This app works completely offline and no internet connection is needed for recognizing the characters.

  * Recognize Kanji characters offline
  * Use a web dictionary to translate characters

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

    plugin: dump
    source: ./src
      "*" : src/

    source: .
    plugin: python
    requirements: ['requirements.txt']
    - libfreetype6
    - libpng16-16
    - libnss3
    - libxcomposite1
    - libxcursor1
    - libxtst6
    - libxrandr2
    - libasound2
    - libglu1-mesa
    - libgles2-mesa
    - fontconfig
    - libxkbcommon0
    - libxkbcommon-x11-0
    - libxi6
    - libegl1
    - shared-mime-info
    - libgdk-pixbuf2.0-0
    - locales-all
    - libxslt1.1
    - xfonts-base
    - xfonts-scalable  

    command: src/dakanji
      - desktop

I would consider myself as a noob regarding snapcraft and linux development in general. So I think I didn’t set any desktop-helper up.

I also tried switching to base: core18. I think this could resolve this issue too. However there I get:

Successfully installed Pillow-8.2.0 PySide2-5.15.2 numpy-1.19.0 shiboken2-5.15.2 tflite-runtime-2.5.0
'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

looks like you want one of the qt parts from…

1 Like

Thank you!

After following the link your linked snapcraft.yaml
I changed the apps part of the snapcraft.yaml to:

    command: desktop-launch $SNAP/src/dakanji
      - kde-neon
      - home
      - opengl
      - network
      - network-bind
      - pulseaudio

Now I hit a different error:

python3: relocation error: /snap/dakanji/x1/kf5/usr/lib/x86_64-linux-gnu/qt5/qml/QtQuick/Controls.2/libqtquickcontrols2plugin.so: symbol _ZN13QQmlDirParserC1Ev version Qt_5_PRIVATE_API not defined in file libQt5Qml.so.5 with link time reference

This error does not help me at all.
Do you have an idea how to resolve this?

sounds like a version mistmatch between your app and the library version …

Is it not possible to include an package from apt in the snap?

I found this thread there it is said:
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
Because now kde-neon can be used in base20 as experimental extension, how can I use it as a stage-package?

It is yes. https://snapcraft.io/docs/build-and-staging-dependencies

Unfortunately I don’t have any experience with the other issues you are facing.

1 Like