The python plugin


#1

The python plugin can be used by either Python 2 or Python 3 based parts using one of the following:

  • a requirements.txt file used to import Python modules
  • a setup.py script for building the project
  • packages installed directly from pip

This plugin uses the common plugin keywords as well as those for “sources”. For more information, see Snapcraft parts metadata.

Additionally, this plugin uses the following plugin-specific keywords:

  • requirements (array)
    List of paths to requirements.txt file(s)
  • constraints (string)
    Path to a constraints file
  • process-dependency-links (bool; default: false)
    Enable the processing of dependency links in pip, which allow one
    project to provide places to look for another project
  • python-packages (list)
    A list of dependencies to get from PyPI
  • python-version (string; default: python3)
    The python version to use. Valid options are: python2 and python3

The python plugin also searches <stage-dir>/usr/bin/<python-interpreter> for a Python interpreter with a basename matching python-version in the <stage> directory. If detected, this takes preference and stage-packages will not use its own interpreter.

See Python applications for a simple example, or search GitHub for projects already using the plugin.

ⓘ This is a snapcraft plugin. See Snapcraft plugins and Supported plugins for further details on how plugins are used.


Snap documentation
Snapcraft build, debug and publishing docs roadmap (page breakdown)
#2

This plugin now supports quite an old version of Python 3 which should be perhaps upgraded to 3.6 or 3.7.

Python 3.5.2 (default, Nov 12 2018, 13:43:14) 
[GCC 5.4.0 20160609] on linux