Which dependencies are needed when using gtk3

My python project works on ubuntu 16.04 and I wanted to create a snap for it, so I started building a snap using nothing more then a snapcraft.yaml in a snap directory and build.snapcraft.io. I should probably start by replicating the tutorials, but I can’t find a tutorial for Gtk3. After asking on rocketchat, I was able to build the project and release it on the store but when I run it I have a ValueError Namespace Gtk not available. This error comes from my
gi,require_version(‘Gtk’, ‘3.0’)

this is my snapcraft.yaml:

name: bzoing
version: '0.2'
summary: Simple calendar alarms for your desktop
description: |
  Bzoing provides a simple way to create task reminder alarms on your desktop
  using Python and Gtk3.
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

    command: desktop-launch $SNAP/bin/bzoing-now
    plugs: [unity7, home, pulseaudio]

    source: https://github.com/lapisdecor/bzoing.git
    # See 'snapcraft plugins'
    plugin: python
       - portaudio19-dev
       - python3-pyaudio
       - python3-gi
after: [desktop-gtk3] 

As you can see I’m already putting python3-gi on stage-packages, and I don’t know how to find any other needed dependencies, since the ones I thought I needed, are already there.
I also use signal and gi.require_version(‘AppIndicator3’, ‘0.1’)
from gi.repository import AppIndicator3 as appindicator. I also use subprocess notify-send.

Not sure what dependencies I need more or how to list them, in ubuntu 16.04 I think I only had to install python3-gi.
Any help on what dependencies I need or if you know a script that can list the dependencies would be welcome. Also please chek my above snapcraft.yaml to see if I’m doing things right.

Thank’s in advance.

So, I did a

apt-cache search python gobject

and after that a

apt-cache search gir1.2

and I finally understood that I needed to include this in stage-packages

gir1.2-gtk-3.0   # this is necessary for gi.require('Gtk', '3.0')
gir1.2-appindicator3-0.1     # this is needed to show icon on system tray

Still working on notify-send, since it’s a system command, I did

man nontify-send

and find out that it’s a freedesktop.org program, so I’ve included x11 in app plugs, Still not working.

Edit: using debian package search https://www.debian.org/distrib/packages#search_packages I found that notify-send is installed with libnotify-bin so I included this package on stage-packages, so now I get notifications.

Edit: I have a problem now with alsa, it seems I can’t access alsa.conf maybe I need a plug? Also, do I really need pulseaudio if I’m using alsa?

@willcooke Can you provide some guidance here, or point to someone that might do so?

You need to add to your stage-packages libnotify-bin, which is where the notify-send binary is. To know which deb package contains a certain file, you can use, for instance:

$ dpkg -S notify-send
libnotify-bin: /usr/bin/notify-send
libnotify-bin: /usr/share/man/man1/notify-send.1.gz

Edit: on alsa, I opened a thread on the ex-snapcraft mailing list at the time, I never got it working outside of classic snaps. This is something that the snapd team (who built that alsa interface) at the time told me they would looked at. However, in general, on desktop, you should really use pulseaudio and the associated interface due to conflict in device ownership for services.

I’m using pyaudio and it seems to use alsa. What python package do you recommend to play a sound file (.wav) or can I still use pyaudio with pulseaudio?

I’ll let other python experts on the forum to answer on that one. I never really played audio in python and won’t be of good advice I’m afraid :slight_smile:

I’m trying something similar here: https://github.com/msis/three20s/tree/snapcraft

But on my side I still get this error message:

Traceback (most recent call last):
  File "/snap/three20s/x4/bin/three20s", line 11, in <module>
    load_entry_point('three20s==0.1.0', 'console_scripts', 'three20s')()
  File "/snap/three20s/x4/lib/python3.6/site-packages/pkg_resources/__init__.py", line 476, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/snap/three20s/x4/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2700, in load_entry_point
    return ep.load()
  File "/snap/three20s/x4/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2318, in load
    return self.resolve()
  File "/snap/three20s/x4/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2324, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/snap/three20s/x4/lib/python3.6/site-packages/three20s/__init__.py", line 1, in <module>
    from .core import *
  File "/snap/three20s/x4/lib/python3.6/site-packages/three20s/core.py", line 3, in <module>
    gi.require_version('Notify', '0.7')
  File "/snap/three20s/x4/usr/lib/python3/dist-packages/gi/__init__.py", line 130, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Notify not available

And should we still be using unity7 for new snaps now that it’s “dead”?