Need feedback on building a snap

I need some feedback for making the snap of this cross-platform pyqt app I am developing GitHub - archisman-panigrahi/QuickBib: Get BibTeX from a DOI — fast.

Here is my current snapcraft.yaml — the problems are following

  1. While it builds on my computer (which I used to publish a snap (for amd64 only)), it fails on GitHub Actions due to missing python3.12 (Build & Publish Snap · archisman-panigrahi/QuickBib@44ac867 · GitHub).
  2. The snap looks out of place in my Kubuntu 24.04 setup – it doesn’t follow the system theme, and also, when the pointer goes over it, it falls back to a different looking pointer theme (the corresponding flatpak doesn’t have this issue, therefore I believe that a better integration would be possible with snap).
name: quickbib
version: '0.3.2'
summary: "Get BibTeX from a DOI — fast"
description: |
  QuickBib is a small cross-platform desktop app that retrieves the BibTeX
  entry for a publication from its DOI (Digital Object Identifier). It
  supports DOIs, arXiv IDs and many journal URLs and uses the doi2bib3 library
  as its backend to fetch and format BibTeX entries.
title: QuickBib
contact: https://github.com/archisman-panigrahi/QuickBib
license: GPL-3.0-only
website: https://archisman-panigrahi.github.io/QuickBib/
source-code: https://github.com/archisman-panigrahi/QuickBib
issues: https://github.com/archisman-panigrahi/QuickBib/issues
grade: stable
confinement: strict
base: core24
compression: lzo


apps:
  quickbib:
    command: usr/bin/quickbib
    environment:
      PYTHONPATH: $SNAP/usr/lib/python3/site-packages:$SNAP/usr/lib/python3/dist-packages:$PYTHONPATH
      QT_PLUGIN_PATH: ${SNAP}/usr/lib/x86_64-linux-gnu/qt6/plugins
      QT_QPA_PLATFORM_PLUGIN_PATH: ${SNAP}/usr/lib/x86_64-linux-gnu/qt6/plugins/platforms
      # XDG_DATA_DIRS: $SNAP/usr/share:${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}
    plugs:
      - network
      - x11
      - wayland

parts:
  quickbib:
    plugin: meson
    source: ..
    build-packages:
      - python3-dev
      - pkg-config
      - build-essential
      - meson
      - ninja-build
    stage-packages:
      - python3
      - python3-pyqt6
    # Debug helper: ensure meson.build is at the top of the part source.
    # Some managed build setups copy the repository under a 'project' subdir
    # inside $SNAPCRAFT_PART_SRC; if so, move files up so Meson sees
    # meson.build at $SNAPCRAFT_PART_SRC.
    override-pull: |
      # run the default pull step
      snapcraftctl pull
      echo "---- listing part src after pull (before fix) ----"
      ls -la "$SNAPCRAFT_PART_SRC" || true
      if [ -d "$SNAPCRAFT_PART_SRC/project" ]; then
        echo "Found nested project directory; moving contents up..."
        sh -c 'cp -a "$SNAPCRAFT_PART_SRC/project/." "$SNAPCRAFT_PART_SRC"'
        rm -rf "$SNAPCRAFT_PART_SRC/project"
      fi
      echo "---- listing part src after fix ----"
      ls -la "$SNAPCRAFT_PART_SRC" || true
    override-build: |
      # run the default build step (meson + ninja)
      snapcraftctl build
      echo "---- moving /usr/local -> /usr in part install (if present) ----"
      if [ -d "$SNAPCRAFT_PART_INSTALL/usr/local/bin" ]; then
        mkdir -p "$SNAPCRAFT_PART_INSTALL/usr/bin"
        cp -a "$SNAPCRAFT_PART_INSTALL/usr/local/bin/." "$SNAPCRAFT_PART_INSTALL/usr/bin/" || true
      fi
      if [ -d "$SNAPCRAFT_PART_INSTALL/usr/local/share" ]; then
        mkdir -p "$SNAPCRAFT_PART_INSTALL/usr/share"
        cp -a "$SNAPCRAFT_PART_INSTALL/usr/local/share/." "$SNAPCRAFT_PART_INSTALL/usr/share/" || true
      fi

  python-deps:
    plugin: python
    source: ..
    python-packages:
      - doi2bib3
    stage-packages:
      - python3

lint:
  ignore:
    - classic
    - library:
      - usr/lib/**/lib*.so*
    - metadata:
      - donation

From what I’ve seen, your app uses strict confinement. You can use the kde-neon-6 extension to make creating your Snap easier; it simplifies the creation process and will give it access to several libraries and plugins necessary for the themes to work correctly.

If you want to learn more about the kde-neon-6 extension, you can check out the link below. I use it in several QT apps that I publish.

https://documentation.ubuntu.com/snapcraft/stable/reference/extensions/kde-neon-extensions/

1 Like

@Kyuyrii The link you shared says the following

The extensions are designed for C++ based Qt/KDE Frameworks apps. They don’t provide the bindings needed for PySide2 (Qt for Python) or PyQt apps. The extensions also don’t provide all of the optional Qt libraries. For example, they don’t include Qt3D, QtCharts, QtDataVisualization or QtGamepad.

I am using PyQt6, so this is probably not relevant for me.

But PyQt6 is Qt, and the kde-neon-6 extension provides things relevant for QT apps to function correctly, such as the QT Breeze and Oxygen styles, as well as adding the icon-themes plugin responsible for allowing the app to use the cursors that a theme Snap provides.