linuxmint / warpinator

Share files across the LAN
GNU General Public License v3.0
1.2k stars 81 forks source link

Warpinator snap not working. Errors out with no module named 'gi'. #64

Closed saivinoba closed 3 years ago

saivinoba commented 3 years ago

I'm trying to build a Warpinator snap. The build finishes and snap gets created. However it doesn't launch and gives error message no module 'gi' as below.

Traceback (most recent call last):
  File "/snap/warpinator/x3/usr/bin/warpinator", line 7, in <module>
    from gi.repository import Gio, GLib
ModuleNotFoundError: No module named 'gi'

I have included (as much as I can see) all dependencies as given in debian/control with possible exception of ${*:Depends} expansion. I do not know what packages they install.

I have tried 'desktop-helpers/desktop-launch' method and also 'extensions' method. I have tried to put required dependencies within 'python' plugin and outside under make/meson. Nothing works. Each time the application successfully snaps but does not launch. I tried to create .deb package. It builds and works fine. I installed flatpak and it also works OK. The issue is only on snap-side. Please check discussion in snapcraft.io forum.

The following is the snapcraft.yaml I'm using.

name: warpinator
base: core18
version: '1.0.8'
summary: Share files across the LAN
description: |
  Share files across the LAN.

grade: devel
confinement: devmode
license: GPL-3.0+

package-repositories:
  - type: apt
    ppa: clementlefebvre/grpc

parts:
  pymodules:
    source: .
    plugin: python
    python-version: python3
    build-packages:
    - python3-grpcio
    - python3-grpc-tools
    - python3-protobuf
    stage-packages:
    - python3-grpc-tools
    - python3-grpcio
    - python3-protobuf
    #- python3-gi
    - python3-setproctitle
    - python3-xapp
    - python3-zeroconf
    - python3-cryptography
    - python3-nacl
    - python3-netifaces
    - python3-packaging

  warpinator:
    source: .
    plugin: meson 
    meson-parameters: [ --prefix=/usr ]
    build-packages:
    - software-properties-common
    - apt-utils
    - appstream
    - gcc
    - gettext
    - gnome-pkg-tools
    - meson
    - policykit-1
    - gobject-introspection
    stage-packages:
    #- gir1.2-glib-2.0
    #- gir1.2-gtk-3.0
    #- gir1.2-xapp-1.0
    #- gir1.2-gobject-2.0
    #- gir1.2-cairo-1.0
    #- gettext
    after: [pymodules]

icon: snap/gui/org.x.Warpinator.png

apps:
  warpinator:
    command: usr/bin/warpinator
    extensions: [gnome-3-34]
    #environment:
    #  PYTHONPATH: $SNAP/usr/lib/python3/dist-packages:$SNAP/usr/lib/$ARCH:$SNAP/usr/libexec/$SNAP_PACKAGE_NAME:$PYTHONPATH
    #plugs: ['home','removable-media','network','network-bind']

Currently you may see, I've commented out python3-gi and gir1.2*. It was done based on suggestion that they are provided by 'gnome-3-34 extension', but situation was same when they were included.

Further, if I do not set 'environment', I get "no module named 'gi'" error but if I set environment (PYTHONPATH), I get "no module named 'warpinator'" error and if I include warpinator's path, I get some other error, I think related to missing 'setproctitle'.

I would really appreciate your help regarding this. TIA.

mtwebster commented 3 years ago

Hi,

I've had similar issues trying to package this with AppImage. I know even less about snaps.

The python3-gi package is definitely what you're missing for the gi import. And you need to include those gir* packages you have commented also.

Those packages tell python how to use C api (like gtk, glib) from python. They turn g_foo_bar () into GLib.Foo.bar(). And the gi package makes that work.

There is a path override environment variable for gobject-introspection specifically - I think GI_TYPELIB_PATH, but I think there's more to it than that.

Another issue is the gir packages aren't all you need for those dependencies. You need the actual libraries also (.so files) - when using distro packaging, this is brought in automatically if you install gir1.2-foo-1.0. I think you need to manually modify the headers of the .so files as well (at least it seemed so in appimage).

In appimage, I sort of got the impression of 'just use the system libs' in this situation, which to me defeats the whole purpose.

I'm not sure how robust snap is regarding gobject introspection. My suggestion is to find other snap packages that use gi - anything that depends on glib (not glibc) and/or gtk3+, and is written in python (there are other languages that use the bindings but not as common I think). See how they worked around it.

I shelved my AppImage effort for the time being. Sorry I can't be more help.

mtwebster commented 3 years ago

Closing as this is a packaging issue.