Conventions for including Python package dependencies: stage-packages, python-packages, install_requires, and requirements.txt

As far as I can tell, when using the python plugin there are 4 possible ways to include a python package in a snap:

  1. put an Ubuntu package name in stage-packages (e.g. python3-numpy)
  2. put the PyPI name for the package in python-package (e.g. numpy)
  3. put the PyPI name in the install_requires list for
  4. put the PyPI name in the requirements.txt file.

I’ve already encountered some issues with, for example, including python3-gi in stage-packages, rather than including PyGObject in python-packages. The former yields run-time errors on a minimal PyGTK example while the latter works.

Could someone please speak to the accepted conventions for including python packages?

Any update on this? I am trying to build a core22 snap that has a part using the python plugin.

1 Like

Best would to follow these

1 Like