Consider this minimal reproducer:
name: gitest
base: core20
version: test
summary: Test python gi.repository import
description: |
Test python gi.repository import
grade: devel
confinement: devmode
apps:
gitest:
command: gitest
extensions:
- gnome-3-38
parts:
stub:
plugin: nil
override-build: |
touch $SNAPCRAFT_PART_INSTALL/gitest
chmod +x $SNAPCRAFT_PART_INSTALL/gitest
with
$ snap info gnome-3-38-2004 | grep stable
tracking: latest/stable
latest/stable: 0+git.6ba6040 2021-09-21 (76) 254MB -
this fails when trying to import via GObject introspection:
$ snap run --shell gitest
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
$ python3
Python 3.8.10 (default, Jun 2 2021, 10:49:15)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>> gi.require_version("Gtk", "3.0")
>>> from gi.repository import Gtk
Segmentation fault (core dumped)
with gnome-3-38-2004 from candidate:
$ snap info gnome-3-38-2004 | grep candidate
tracking: latest/candidate
latest/candidate: 0+git.cd626d1 2021-11-16 (87) 259MB -
this works again:
$ python3
Python 3.8.10 (default, Jun 2 2021, 10:49:15)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi.repository import Gtk
(.:354217): dbind-WARNING **: 10:48:50.733: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-vdXnQGroWF: No such file or directory
<stdin>:1: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
>>>
I’ll leave this here for visibility, and might get around to reporting it as a bug later on. I think a new release to stable with this fixed is required. Some automated tests for such things would be a good idea, too.
Edit: Here’s the bug: https://gitlab.gnome.org/Community/Ubuntu/gnome-sdk/-/issues/7