I’ve been working on snapping a Python 3/Kivy 1.10 application, which has not been easy. It is now working just fine in devmode
confinement, but as soon as I switch to strict
confinement, I get the following error on trying to run the application.
[CRITICAL] [Window ] Unable to find any valuable Window provider. egl_rpi - ImportError: cannot import name ‘bcm’ File “/snap/omission/x1/lib/python3.5/site-packages/kivy/core/init.py”, line 59, in core_select_lib fromlist=[modulename], level=0) File “/snap/omission/x1/lib/python3.5/site-packages/kivy/core/window/window_egl_rpi.py”, line 12, in from kivy.lib.vidcore_lite import bcm, egl
sdl2 - RuntimeError: b’Could not initialize UDEV’ File “/snap/omission/x1/lib/python3.5/site-packages/kivy/core/init.py”, line 67, in core_select_lib cls = cls() File “/snap/omission/x1/lib/python3.5/site-packages/kivy/core/window/window_sdl2.py”, line 140, in init super(WindowSDL, self).init() File “/snap/omission/x1/lib/python3.5/site-packages/kivy/core/window/init.py”, line 899, in init self.create_window() File “/snap/omission/x1/lib/python3.5/site-packages/kivy/core/window/window_sdl2.py”, line 269, in create_window self.fullscreen, resizable, state) File “kivy/core/window/_window_sdl2.pyx”, line 84, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window (/tmp/pip-build-yrimf4na/kivy/kivy/core/window/_window_sdl2.c:2290) File “kivy/core/window/_window_sdl2.pyx”, line 57, in kivy.core.window._window_sdl2._WindowSDL2Storage.die (/tmp/pip-build-yrimf4na/kivy/kivy/core/window/_window_sdl2.c:1872)
x11 - ImportError: No module named ‘kivy.core.window.window_x11’ File “/snap/omission/x1/lib/python3.5/site-packages/kivy/core/init.py”, line 59, in core_select_lib fromlist=[modulename], level=0)
My snapcraft.yaml
is as follows:
name: omission # you probably want to 'snapcraft register <name>'
version: '1.0rc2' # just for humans, typically '1.2+git' or '1.3.2'
summary: A deceptively simple word puzzle. # 79 char long summary
description: |
Omission challenges you to put your language detective skills to the test with
a deceptively simple challenge - Find the missing letter! A famous quotation
will be displayed, with all the instances of a single letter removed. How fast
can you figure out the missing letter? It's a race to beat the clock (unless
you choose another mode) as you try to complete as many passages as you can.
The faster you answer, the more points you gain.
icon: snap/gui/omission_icon.png
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: strict
parts:
omission:
# See 'snapcraft plugins'
plugin: python
python-version: python3
source: .
stage-packages:
- build-essential
- git
- python3-dev
- ffmpeg
- libsdl2-dev
- libsdl2-image-dev
- libsdl2-mixer-dev
- libsdl2-ttf-dev
- libportmidi-dev
- libswscale-dev
- libavformat-dev
- libavcodec-dev
- zlib1g-dev
- libgstreamer1.0-0
- libgstreamer1.0-dev
- gstreamer1.0-plugins-base
- gstreamer1.0-plugins-good
- gstreamer1.0-plugins-bad
- gstreamer1.0-plugins-ugly
- xclip
- libmtdev1
- libmtdev-dev
- libgl1-mesa-dri
- libgl1-mesa-glx
- libgles2-mesa
- cython3
launcher:
plugin: dump
source: ./linux_deploy
organize:
'launch_omission': 'bin/launch_omission'
apps:
omission:
command: bin/launch_omission
#command: bin/omission
plugs:
- pulseaudio
- x11
- opengl
- alsa
- mount-observe
My setup.py
is:
#!/usr/bin/env python
from setuptools import setup
setup(name='Omission',
version='1.0',
description='A deceptively simple word puzzle.',
author='MousePaw Games',
author_email='info@mousepawgames.com',
url='https://www.mousepawgames.com/omission',
license='BSD-3',
packages=['omission',
'omission.data',
'omission.game',
'omission.interface'],
package_data={'omission': ['resources/audio/*.ogg',
'resources/content/*.txt',
'resources/font/open-dyslexic/*.otf',
'resources/font/orbitron/*.otf',
'resources/font/source-sans-pro/*.otf',
'resources/icons/*.png',
'interface/omission.kv'
]
},
entry_points={'gui_scripts': ['omission = omission.__main__:main']},
install_requires=[
'cython == 0.25.2',
'kivy >= 1.10.0',
'appdirs >= 1.4.3'
],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
'Operating System :: Microsoft :: Windows',
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3',
'Topic :: Games/Entertainment :: Puzzle Games'
]
)
And lastly, my start script (borrowed from @popey, thanks again) is as follows:
#!/bin/bash
case "$SNAP_ARCH" in
"amd64") ARCH='x86_64-linux-gnu'
;;
"i386") ARCH='i386-linux-gnu'
;;
*)
echo "Unsupported architecture for this app build"
exit 1
;;
esac
export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH:$LD_LIBRARY_PATH
# XKB config
export XKB_CONFIG_ROOT=$SNAP/usr/share/X11/xkb
export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/pulseaudio:$LD_LIBRARY_PATH
# Mesa Libs
export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/mesa:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/mesa-egl:$LD_LIBRARY_PATH
# XDG Config
export XDG_CONFIG_DIRS=$SNAP/etc/xdg:$XDG_CONFIG_DIRS
export XDG_CONFIG_DIRS=$SNAP/usr/xdg:$XDG_CONFIG_DIRS
# Note: this doesn't seem to work, QML's LocalStorage either ignores
# or fails to use $SNAP_USER_DATA if defined here
export XDG_DATA_DIRS=$SNAP_USER_DATA:$XDG_DATA_DIRS
export XDG_DATA_DIRS=$SNAP/usr/share:$XDG_DATA_DIRS
# Workaround in snapd for proprietary nVidia drivers mounts the drivers in
# /var/lib/snapd/lib/gl that needs to be in LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/var/lib/snapd/lib/gl:$LD_LIBRARY_PATH
# Not good, needed for fontconfig
export XDG_DATA_HOME=$SNAP_USER_DATA/usr/share
# Font Config
export FONTCONFIG_PATH=$SNAP/etc/fonts/config.d
export FONTCONFIG_FILE=$SNAP/etc/fonts/fonts.conf
# Tell libGL where to find the drivers
export LIBGL_DRIVERS_PATH=$SNAP/usr/lib/$ARCH/dri
# Necessary for the SDK to find the translations directory
export APP_DIR=$SNAP
# Use GTK styling for running under Unity 7
#export DESKTOP_SESSION=ubuntu
#export XDG_SESSION_DESKTOP=ubuntu
#export XDG_CURRENT_DESKTOP=Unity
#export LIBGL_DEBUG="verbose"
export XLOCALEDIR="$SNAP/usr/share/X11/locale"
export LOCPATH="$SNAP/usr/lib/locale"
$SNAP/bin/omission
Any ideas how to fix this?
(On a side note, if anyone spots packages in my snapcraft.yaml
that I don’t need, please speak up. Trying to cut my currently ~350MB snap file down in size SIGNIFICANTLY.)
Thank you!