Python Plugin + Gnome 3 Extension Error

Hi, I’m having trouble snapping a wxWidgets based python app. wxWidgets relies on gtk3 from what I can tell looking at the dependencies at

I was able to simplify the snapcraft.yaml file to just the python plugin (with a random source posted here) and the gnome extension, so I don’t think I’m doing anything wrong (but happy to learn if I am messing something up). Removing the gnome extension from the app makes the error about read only file system disappear.


+ snapcraftctl build
+ python3 -m venv /root/parts/test/install
+ SNAPCRAFT_PYTHON_VENV_INTERP_PATH=/root/parts/test/install/bin/python3
+ pip install -U pip setuptools wheel
Collecting pip
  Using cached pip-22.3.1-py3-none-any.whl (2.1 MB)
Collecting setuptools
  Using cached setuptools-65.6.3-py3-none-any.whl (1.2 MB)
Collecting wheel
  Using cached wheel-0.38.4-py3-none-any.whl (36 kB)
Installing collected packages: pip, setuptools, wheel
  Attempting uninstall: pip
    Found existing installation: pip 20.0.2
    Uninstalling pip-20.0.2:
ERROR: Could not install packages due to an EnvironmentError: [Errno 30] Read-only file system: ''

Failed to build 'test'.

Recommended resolution:
Check the build logs and ensure the part's configuration and sources are correct.
Run the same command again with --debug to shell into the environment if you wish to introspect this failure

From the following simplified build script:

name: test
summary: summary
description: |

version: '0.1'
base: core20
confinement: strict
grade: stable

    command: usr/bin/python
    extensions: [gnome-3-38]

    plugin: python

I couldn’t reproduce this exact issue but it seems that it’s trying to remove a package from a base snap? @tigarmo, wdyt?

In the meantime, can you try to pack your snap using base core22 and extension gnome to see if it behaves as expected?

Interesting. It’s producing a different error on Canonical build servers.

Skipping pull gnome-3-38-extension (already ran)
Building atestsnap 
+ snapcraftctl build
+ python3 -m venv /build/atestsnap/parts/atestsnap/install
+ SNAPCRAFT_PYTHON_VENV_INTERP_PATH=/build/atestsnap/parts/atestsnap/install/bin/python3
+ pip install -U pip setuptools wheel
Traceback (most recent call last):
  File "/snap/gnome-3-38-2004-sdk/current/usr/bin/pip", line 6, in <module>
    from pkg_resources import load_entry_point
ModuleNotFoundError: No module named 'pkg_resources'

I’ll change it to core22 and see how that goes.

core22 doesn’t have that error but the snap fails to release. On launchpadlibrarian I can see the following failure:

    Store upload failed:
        package contains external symlinks: bin/python -> python3, bin/python3 -> /snap/gnome-42-2204-sdk/48/usr/bin/python3.10, bin/python3.10 -> python3

So core22 + python plugin + gnome extension seems to also be a no-go

Quick edit: The unable to release is a bit of a red herring. It’s a good thing because the snap doesn’t work as expected because of the broken $SNAP/bin/python3 symlink

user@host:~$ ls -l /snap/atestsnap/x1/bin/python3
lrwxrwxrwx 1 root root 45 Jan  7 22:07 /snap/atestsnap/x1/bin/python3 -> /snap/gnome-42-2204-sdk/48/usr/bin/python3.10

That gnome extension really takes over all the python stuff for some reason.

1 Like

According to this post, it looks like someone is working on the python issues. I hope that work also includes the issue with the gnome ext.

@goodsoftworx Thanks for the link! Looks like they still haven’t solved the issue yet. I did a diff of the environment in override-build and by looking at a diff between with and without the gnome extension, I think my issue here can be remedied by a simple unset PYTHON_PATH in override-build.

I’m going to try that out and see if it resolves the python symlink issue for core22 then I’ll test it out to see if it fixes the readonly filesystem I was having for core20.

Can only post images so here’s what the diff looks like:

So it didn’t release. The symlinks are still there and it fails to release to the store. My fear is that the gnome extension is being overlayed on top of my snap and thus it’s filesystem has precedence. I’ll check out the override-prime step to see what can be done there, if anything.

There are workarounds in the video-downloader snap that seem to be working for me. Everything needed to get python working with the gnome plugin is noted with #WORKAROUND.

An abbreviated snapcraft.yaml which includes just the fixes I need is

base: core22
  # WORKAROUND: Add python modules in Snap to search path
  PYTHONPATH: ${SNAP}/lib/python3.10/site-packages:${SNAP}/usr/lib/python3/dist-packages

    command: usr/bin/video-downloader
      # HINT: Adds plugs and changes environment variables when building and running
      - gnome


      # WORKAROUND: The python plugin is broken with gnome extension
      - PYTHONPATH: ""
      # WORKAROUND: Skip venv from python plugin
      - -bin/activate
      - -bin/activate.csh
      - -bin/
      - -bin/Activate.ps1
      - -bin/python
      - -bin/python3
      - -bin/python3.10
      - -bin/pip
      - -bin/pip3
      - -bin/pip3.10
      - -pyvenv.cfg
1 Like

Is this still needed?

You still need to remove pyvenv.cfg and other python files from being staged

Yes, but do I have to use PYTHONPATH ? I’m trying to access python3-xdg on a snap and without configuration I can’t import xdg from the main program.

No you don’t that PYTHONPATH is for build time not runtime. Runtime is already set by the extension you use.

That’s what I thought but I have python3-xdg on stage-packages and the main program cant import xdg.

from xdg.BaseDirectory import save_data_path
ModuleNotFoundError: No module named 'xdg'

The PYTHONPATH needs to be set for runtime. In which folder it’s installed, check it first. Then add that folder in PYTHONPATH. Eg: If it’s installed /usr/lib/python3/site-packages then

      PYTHONPATH: $SNAP/usr/lib/python3/site-packages:$PYTHONPATH

It’s actually in dist-packages, not site-packages. I’m gonna try this and see if it works.

It depends. It’s not hardcoded that it has to be that only.