Resolve "Namespace Gtk not available" on core18

I’m trying to snap package Lutris: Lutris snap · Issue #17 · lutris/agora · GitHub. My work is at Lutris snap · Issue #17 · lutris/agora · GitHub but it’s basically just a snapcraft.yaml file with a python3 part so far. When I run my built and installed snap, I get the error:

$ lutris Traceback (most recent call last): File “/snap/lutris/x1/bin/lutris”, line 33, in from lutris.gui.application import Application File “/snap/lutris/x1/lib/python3.6/site-packages/lutris/gui/application.py”, line 27, in gi.require_version(‘Gdk’, ‘3.0’) # NOQA # isort:skip File “/snap/lutris/x1/usr/lib/python3/dist-packages/gi/init.py”, line 130, in require_version raise ValueError(‘Namespace %s not available’ % namespace) ValueError: Namespace Gdk not available

I can resolve this error by removing “base: core18” and then adding desktop-launch from the launch command as in Exec: python: not found. I prefer to use core18 because I’m on Ubuntu 18.04. Building for 16.04 either requires snapcraft cleanbuild which is exceedingly slow or using Docker which is kind of inconvenient.

I saw that someone had a similar problem at Building on core18, failure on pulling core18 on build.snapcraft.io but I don’t get from that thread what the solution is. Bug #1800057 “Remote parts don't seem to work in snapcraft 3.0” : Bugs : Snapcraft says that desktop-launch comes from a remote part in “desktop-helper”. I tried adding all of the stage-packages from the parts in “desktop-helper” into my snapcraft.yaml but that did nothing. I tried adding all of the parts and source from desktop-helper into my project wholesale, but then it failed to build. I tried removing PyYAML, PyGObject, and evdev from install_requires in setup.py because they should be installed by the python-gi, python-yaml, and python-evdev package, but that didn’t do anything for me.

How do I resolve Python not seeing Gdk and Gtk?

I doubt this can be solved by exporting proper environment variables.

I have the same issue.
How can we include GTK3+ in our snaps when using base: core18 , so that Python3 will see it?