I’m also stuck with this problem, a python app that uses gtk3. Seeing that the python plugin is not compatible with the gnome-3-38 extension in core20, I think I’ll have to change my code, which uses python features up to v3.9, to work with python 3.6 and core18. I tried upgrading python in core18 following instructions on this board, but ran into several problems with mixed python versions. I’m sure these conflicts will get sorted out one day, so maybe I should just be patient and focus on other things.
Edit: I gave it another go and got it working (core20, python3.9, gnome-3-38). It’s kind of brittle, because it manipulates PATH and PYTHONPATH to prevent a conflict with gnome-3-38’s python. Here’s the partial snapcraft.yaml in case this helps anyone:
base: core20
parts:
myapp:
plugin: python
source: .
build-environment:
- SNAPCRAFT_PYTHON_INTERPRETER: python3.9
# python3.9 lives in $SNAPCRAFT_PART_INSTALL/bin
- PATH: $SNAPCRAFT_PART_INSTALL/bin:$PATH
- PYTHONPATH: ''
build-packages:
- python3.9-venv
- python3.9-dev
# ...
override-build: |
# Work around a bug in snapcraft python plugin
# https://forum.snapcraft.io/t/build-a-snap-with-any-version-of-python-i-want/10420/8
rm -rf $SNAPCRAFT_PART_INSTALL/usr/lib/python3.9/distutils
cp -r /usr/lib/python3.9/distutils $SNAPCRAFT_PART_INSTALL/usr/lib/python3.9/distutils
mkdir -p $SNAPCRAFT_PART_INSTALL/usr/include/
cp -r /usr/include/python3.9 $SNAPCRAFT_PART_INSTALL/usr/include/python3.9
snapcraftctl build
stage-packages:
- python3.9-venv
apps:
myapp:
plugs:
- mpris
- audio-playback
# ...
extensions: [gnome-3-38]
# must use the interpreter from bin/ (not usr/bin/)
command: bin/python3.9 -m myapp