Gnome extension and python binding has issue

I made this snap for the frog project.

name: frog # you probably want to 'snapcraft register <name>'
base: core22 # the base snap is the execution environment for this snap
version: '1.2.0' # just for humans, typically '1.2+git' or '1.3.2'
summary: Single-line elevator pitch for your amazing snap # 79 char long summary
description: |
  This is my-snap's description. You have a paragraph or two to tell the
  most important story about your snap. Keep it under 100 words though,
  we live in tweetspace and your description wants to look good in the snap
  store.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

  
parts:
  frog:
    plugin: meson
    source-type: git
    source: https://github.com/TenderOwl/Frog.git
    source-tag: "1.2.0"
    meson-parameters:
      - --prefix=/usr
      - --buildtype=release
    # See 'snapcraft plugins'
    build-packages:
      - meson
      - ninja-build
      - python3
      - python3-gi 
      - gettext
      - pkg-config
      - libglib2.0-dev
      - desktop-file-utils
      - appstream
      - libappstream-dev 
    stage-packages:
      - python-is-python3
      - python3
      - python3-pyzbar
      - python3-pydbus 
      - python3-tesserocr 
      - tesseract-ocr 
    override-pull: |
      craftctl default
    # WORKAROUND: Point icon directly to SVG otherwise snapcraft can't find it
      sed -e 's|Icon=com.github.tenderowl.frog|Icon=/usr/share/icons/hicolor/scalable/apps/com.github.tenderowl.frog.svg|' -i data/com.github.tenderowl.frog.desktop.in
      
slots:
  frog:
    interface: dbus
    bus: session
    name: com.github.tenderowl.frog
plugs:
  pictures:
    interface: personal-files
    write:
      - $HOME/Pictures
apps:
  frog:
    command: usr/bin/frog
    common-id: com.github.tenderowl.frog
    extensions: [gnome]
    #desktop: usr/share/applications/com.github.tenderowl.frog.desktop
    environment:
      # WORKAROUND: Add python modules in Snap to search path
      PYTHONPATH: ${SNAP}/lib/python3.10/site-packages:${SNAP}/usr/lib/python3/dist-packages
      XDG_DATA_HOME: $SNAP_USER_DATA/.local/share 
    plugs:
      - home
      - pictures

But whenever I run /snap/bin/frog, I get,

/snap/frog/x1/gnome-platform/command-chain/desktop-launch: /snap/frog/x1/usr/bin/frog: /snap/gnome-42-2204-sdk/current/usr/bin/python3: bad interpreter: No such file or directory
/snap/frog/x1/gnome-platform/command-chain/desktop-launch: line 603: /snap/frog/x1/usr/bin/frog: Success

This issue persists with the snap drawing also. Also the icon is not showing in the menu. Can anyone help me with a fix? I’ve already stormed the internet.

Is this the same problem described in Python Plugin + Gnome 3.38 Extension Error? This must be properly fixed, but in the meantime there’s a workaround suggestion there.

Yes, I was studying from the video-downloader snap, but I was not able to make things work. Can you help me? Maybe I’m not understanding the issue, and what is needed to solve it.

I don’t think you’re doing anything wrong. I think the issue here is that you’re using the meson plugin, which seems to be correct for your repository and the meson plugin doesn’t do any special tricks like the python plugin does such as

So, in my opinion, you will need to add an override-build step and “fix” the interpreter path of ${CRAFT_PART_INSTALL}/usr/bin/frog such that the interpreter becomes /usr/bin/env python3.

This is just a quick analysis of the issue so it may be wrong.

Okay so getting this now

Warning: Schema “org.gnome.system.locale” has path “/system/locale/”.  Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy” has path “/system/proxy/”.  Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.http” has path “/system/proxy/http/”.  Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.https” has path “/system/proxy/https/”.  Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.ftp” has path “/system/proxy/ftp/”.  Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.socks” has path “/system/proxy/socks/”.  Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Traceback (most recent call last):
  File "/snap/frog/x3/usr/bin/frog", line 59, in <module>
    from frog import main
ModuleNotFoundError: No module named 'frog'

The snap file

name: frog # you probably want to 'snapcraft register <name>'
base: core22 # the base snap is the execution environment for this snap
version: '1.2.0' # just for humans, typically '1.2+git' or '1.3.2'
summary: Single-line elevator pitch for your amazing snap # 79 char long summary
description: |
  This is my-snap's description. You have a paragraph or two to tell the
  most important story about your snap. Keep it under 100 words though,
  we live in tweetspace and your description wants to look good in the snap
  store.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots
compression: lzo
environment:
  # WORKAROUND: Add python modules in Snap to search path
  PYTHONPATH: ${SNAP}/lib/python3.10/site-packages:${SNAP}/usr/lib/python3/dist-packages
layout:
  /usr/share/frog:
    bind: $SNAP/usr/share/frog
parts:
  meson:
    plugin: python
    source: https://github.com/mesonbuild/meson.git
    source-tag: 1.0.0
    build-environment:
      # WORKAROUND: The python plugin is broken with gnome extension
      - PATH: ${CRAFT_PART_INSTALL}/bin:${PATH}
      - PYTHONPATH: ""
    stage:
      # WORKAROUND: Skip venv from python plugin
      - -bin/activate
      - -bin/activate.csh
      - -bin/activate.fish
      - -bin/Activate.ps1
      - -bin/python
      - -bin/python3
      - -bin/python3.10
      - -bin/pip
      - -bin/pip3
      - -bin/pip3.10
      - -pyvenv.cfg
      
      
  frog:
    after: [meson]
    plugin: meson
    source: https://github.com/TenderOwl/Frog.git
    source-type: git
    source-tag: "1.2.0"
    meson-parameters:
      - --prefix=/usr
      - --buildtype=release
    # See 'snapcraft plugins'
    build-packages:
      - ninja-build
      - gettext
      - pkg-config
      - glibc-source
      - libglib2.0-dev
      - desktop-file-utils
      - appstream
      - libappstream-dev 
      - libglib2.0-bin
      - libappstream-glib-dev
      - python-is-python3
      - python3-gi
      - python-gi-dev 
      - python3-pyzbar
      - python3-pydbus 
      - python3-tesserocr 
      - tesseract-ocr 
      - libnotify-dev
      - libleptonica-dev
      - libgtk-3-dev
    stage-packages:
      - gettext
      - pkg-config
      - glibc-source
      - libglib2.0-0
      - libglib2.0-dev
      - desktop-file-utils
      - appstream
      - libappstream-dev 
      - libglib2.0-bin
      - libappstream-glib-dev
      - python-is-python3
      - python3-gi
      - python-gi-dev 
      - python3-pyzbar
      - python3-pydbus 
      - python3-tesserocr 
      - tesseract-ocr 
      - libnotify-dev
      - libleptonica-dev
      - libgtk-3-dev
    override-pull: |
      craftctl default
      # WORKAROUND: Point icon directly to SVG otherwise snapcraft can't find it
      sed -e 's|Icon=com.github.tenderowl.frog|Icon=/usr/share/icons/hicolor/scalable/apps/com.github.tenderowl.frog.svg|' -i data/com.github.tenderowl.frog.desktop.in
    override-build: |
      craftctl default
      # WORKAROUND: Use python from search path, the path detected by meson doesn't exist when running the Snap
      sed -e '1c#!/usr/bin/env python3' -i "${CRAFT_PART_INSTALL}/usr/bin/frog"
    parse-info: [/usr/share/appdata/com.github.tenderowl.frog.appdata.xml]
    organize:
      snap/frog/current/usr: usr
slots:
  frog:
    interface: dbus
    bus: session
    name: com.github.tenderowl.frog
plugs:
  pictures:
    interface: personal-files
    write:
      - $HOME/Pictures
apps:
  frog:
    command: usr/bin/frog
    common-id: com.github.tenderowl.frog
    extensions: [gnome]
    desktop: usr/share/applications/com.github.tenderowl.frog.desktop
    environment:
      XDG_DATA_HOME: $SNAP_USER_DATA/.local/share 
    plugs:
      - home
      - pictures
      - network

      `````

it might be that the global environment: at the top will be ignored when you set another environment: in your apps: section.

I’d try to move the PYTHONPATH down to the apps: block…

Hey your solution didn’t help. The error is same.

I made some changes in the yaml file and the file is this,

name: frog # you probably want to 'snapcraft register <name>'
base: core22 # the base snap is the execution environment for this snap
version: '1.2.0' # just for humans, typically '1.2+git' or '1.3.2'
summary: Single-line elevator pitch for your amazing snap # 79 char long summary
description: |
  This is my-snap's description. You have a paragraph or two to tell the
  most important story about your snap. Keep it under 100 words though,
  we live in tweetspace and your description wants to look good in the snap
  store.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots
compression: lzo
#environment:
  # WORKAROUND: Add python modules in Snap to search path
 # PYTHONPATH: ${SNAP}/lib/python3.10/site-packages:${SNAP}/usr/lib/python3/dist-packages
layout:
  /usr/share/frog:
    bind: $SNAP/usr/share/frog
  /usr/local/lib/python3.10/dist-packages/frog:
    bind: $SNAP/usr/local/lib/python3.10/dist-packages/frog
parts:
  meson:
    plugin: python
    source: https://github.com/mesonbuild/meson.git
    source-tag: 1.0.0
    build-environment:
      # WORKAROUND: The python plugin is broken with gnome extension
      - PATH: ${CRAFT_PART_INSTALL}/bin:${PATH}
      - PYTHONPATH: ""
    stage:
      # WORKAROUND: Skip venv from python plugin
      - -bin/activate
      - -bin/activate.csh
      - -bin/activate.fish
      - -bin/Activate.ps1
      - -bin/python
      - -bin/python3
      - -bin/python3.10
      - -bin/pip
      - -bin/pip3
      - -bin/pip3.10
      - -pyvenv.cfg
      
      
  frog:
    after: [meson]
    plugin: meson
    source: https://github.com/TenderOwl/Frog.git
    source-type: git
    source-tag: "1.2.0"
    meson-parameters:
      - --prefix=/usr
      - --buildtype=release
    # See 'snapcraft plugins'
    build-packages:
      - ninja-build
      - gettext
      - pkg-config
      - glibc-source
      - libglib2.0-dev
      - desktop-file-utils
      - appstream
      - libappstream-dev 
      - libglib2.0-bin
      - libappstream-glib-dev
      - python-is-python3
      - python3-gi
      - python-gi-dev 
      - python3-pyzbar
      - python3-pydbus 
      - python3-tesserocr 
      - tesseract-ocr 
      - libnotify-dev
      - libleptonica-dev
      - libgtk-3-dev
    stage-packages:
      - gettext
      - pkg-config
      - glibc-source
      - libglib2.0-0
      - libglib2.0-dev
      - desktop-file-utils
      - appstream
      - libappstream-dev 
      - libglib2.0-bin
      - libappstream-glib-dev
      - python-is-python3
      - python3-gi
      - python-gi-dev 
      - python3-pyzbar
      - python3-pydbus 
      - python3-tesserocr 
      - tesseract-ocr 
      - libnotify-dev
      - libleptonica-dev
      - libgtk-3-dev
    override-pull: |
      craftctl default
      # WORKAROUND: Point icon directly to SVG otherwise snapcraft can't find it
      sed -e 's|Icon=com.github.tenderowl.frog|Icon=/usr/share/icons/hicolor/scalable/apps/com.github.tenderowl.frog.svg|' -i data/com.github.tenderowl.frog.desktop.in
    override-build: |
      craftctl default
      # WORKAROUND: Use python from search path, the path detected by meson doesn't exist when running the Snap
      sed -e '1c#!/usr/bin/env python3' -i "${CRAFT_PART_INSTALL}/usr/bin/frog"
    parse-info: [/usr/share/appdata/com.github.tenderowl.frog.appdata.xml]
    organize:
      snap/frog/current/usr: usr
slots:
  frog:
    interface: dbus
    bus: session
    name: com.github.tenderowl.frog
plugs:
  pictures:
    interface: personal-files
    write:
      - $HOME/Pictures
apps:
  frog:
    command: usr/bin/frog
    common-id: com.github.tenderowl.frog
    extensions: [gnome]
    desktop: usr/share/applications/com.github.tenderowl.frog.desktop
    environment:
      PYTHONPATH: ${SNAP}/lib/python3.10/site-packages:${SNAP}/usr/lib/python3/dist-packages
      XDG_DATA_HOME: $SNAP_USER_DATA/.local/share 
    plugs:
      - home
      - pictures
      - network

But still I’m getting some error

Warning: Schema “org.gnome.system.locale” has path “/system/locale/”.  Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy” has path “/system/proxy/”.  Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.http” has path “/system/proxy/http/”.  Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.https” has path “/system/proxy/https/”.  Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.ftp” has path “/system/proxy/ftp/”.  Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.socks” has path “/system/proxy/socks/”.  Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.

** (process:21265): WARNING **: 20:53:34.490: Failed to load shared library 'libgtk-4.so.1' referenced by the typelib: /snap/frog/x2/gnome-platform/usr/lib/x86_64-linux-gnu/libgtk-4.so.1: undefined symbol: hb_font_get_var_coords_design
Traceback (most recent call last):
  File "/snap/frog/x2/usr/bin/frog", line 59, in <module>
    from frog import main
  File "/usr/local/lib/python3.10/dist-packages/frog/main.py", line 39, in <module>
    from gi.repository import Gtk, Gio, GLib, Notify, Adw, GdkPixbuf
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 672, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 632, in _load_backward_compatible
  File "/snap/frog/x2/usr/lib/python3/dist-packages/gi/importer.py", line 150, in load_module
    dynamic_module = load_overrides(introspection_module)
  File "/snap/frog/x2/usr/lib/python3/dist-packages/gi/overrides/__init__.py", line 118, in load_overrides
    override_mod = importlib.import_module(override_package_name)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/snap/frog/x2/usr/lib/python3/dist-packages/gi/overrides/Gtk.py", line 111, in <module>
    class Widget(Gtk.Widget):
  File "/snap/frog/x2/usr/lib/python3/dist-packages/gi/module.py", line 168, in __getattr__
    interfaces = tuple(interface for interface in get_interfaces_for_object(info)
  File "/snap/frog/x2/usr/lib/python3/dist-packages/gi/module.py", line 94, in get_interfaces_for_object
    interfaces.append(getattr(module, name))
  File "/snap/frog/x2/usr/lib/python3/dist-packages/gi/overrides/__init__.py", line 32, in __getattr__
    return getattr(self._introspection_module, name)
  File "/snap/frog/x2/usr/lib/python3/dist-packages/gi/module.py", line 207, in __getattr__
    wrapper = metaclass(name, bases, dict_)
  File "/snap/frog/x2/usr/lib/python3/dist-packages/gi/types.py", line 247, in __init__
    register_interface_info(cls.__info__.get_g_type())
TypeError: must be an interface

WARNING **: 20:53:34.490: Failed to load shared library ‘libgtk-4.so.1’

That file comes from the libgtk-4-1 package so you should add that to the frog.stage-packages section to resolve that error.

Whenever I see an error like that, I head to https://packages.ubuntu.com/ and use the Search the contents of packages feature to find out the package name for a given file.

I am trying to find out a website where it’ll show, that let’s take a package X gives /usr/bin/X, /usr/share/applications/X.desktop and all the other library that’ll add. Just like it shows in Gdebi for a deb file. Is there any website?

Now I’m getting this issue,

Warning: Schema “org.gnome.system.locale” has path “/system/locale/”.  Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy” has path “/system/proxy/”.  Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.http” has path “/system/proxy/http/”.  Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.https” has path “/system/proxy/https/”.  Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.ftp” has path “/system/proxy/ftp/”.  Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.socks” has path “/system/proxy/socks/”.  Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/frog/screenshot_backend.py", line 38, in <module>
    from PIL import Image
ModuleNotFoundError: No module named 'PIL'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/snap/frog/x1/usr/bin/frog", line 59, in <module>
    from frog import main
  File "/usr/local/lib/python3.10/dist-packages/frog/main.py", line 44, in <module>
    from .screenshot_backend import ScreenshotBackend
  File "/usr/local/lib/python3.10/dist-packages/frog/screenshot_backend.py", line 40, in <module>
    import Image
ModuleNotFoundError: No module named 'Image'

Hey any solution about this? @ogra

Hey can you help me out about this?

This is a generic python error and not related to snap. The python image/pil library comes from https://packages.ubuntu.com/jammy/python3-pil. Add that to your stage packages and just rinse and repeat for each error you encounter.