The python
plugin can be used by either Python 2 or Python 3 based parts using a setup.py
script for building the project, or using a package published to PyPI, and optionally any of the following:
This plugin uses the common plugin keywords as well as those for “sources”. For more information, see Snapcraft parts metadata.
Plugin-specific features and syntax are dependent on which base is being used, as outlined below:
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.
This plugin uses the following plugin-specific keywords:
python-requirements
(list)
List of paths to requirements.txt file(s). Paths are relative to the value provided by the source
key.python-constraints
(list)
List of paths to constraint files.python-packages
(list, default: [pip, setuptools, wheel])pip
. This supports the same syntax as the pip install
command.This plugin also interprets these specific build-environment entries:
PARTS_PYTHON_INTERPRETER
(default: python3)
The interpreter binary to search for in PATH
.
PARTS_PYTHON_VENV_ARGS
Additional arguments for venv.
By default, this plugin uses Python from the base snap. If a part using this plugin uses a build-base other than that of the base, or a different interpreter is desired, it must be bundled in the snap (including venv) and must be in PATH.
It is required to bundle python when creating a snap that uses classic confinement, this can be accomplished on Ubuntu by adding stage-packages (i.e.; python3-venv).
Use of python3- in stage-packages will force the inclusion of the python interpreter.
Requires Snapcraft version 7.0+ for core22
.
Requires Snapcraft version 8.0+ for core24
.
This plugin uses the following plugin-specific keywords:
requirements
(array)
List of paths to requirements.txt file(s). Paths are relative to the value provided by the source
key.constraints
(string)
Path to a constraints file.python-packages
(list)
A list of dependencies to install using pip
. This supports the same syntax as the pip install
command.This plugin also interprets these specific build-environment entries:
SNAPCRAFT_PYTHON_INTERPRETER
(default: python3)
The interpreter binary to search for in PATH
.
SNAPCRAFT_PYTHON_VENV_ARGS
Additional arguments for venv.
By default, this plugin uses Python from the base snap. If a part using this plugin uses a build-base other than that of the base, or a different interpreter is desired, it must be bundled in the snap (including venv) and must be in PATH.
It is required to bundle python when creating a snap that uses classic confinement, this can be accomplished on Ubuntu by adding stage-packages (i.e.; python3-venv).
Use of python3- in stage-packages will force the inclusion of the python interpreter.
Requires Snapcraft version 4.0+.
This plugin uses the following plugin-specific keywords:
requirements
(array)
List of paths to requirements.txt file(s). Paths are relative to the value provided by the source
key.
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 install using pip
. This supports the same syntax as the pip install
command. For example:
python-packages:
- docopt == 0.6.1 # Install specific versions
- git+https://github.com/inuits/mkdocs-factsheet.git # Install from a git repository
- https://github.com/cmacmackin/markdown-include/archive/v0.5.1.tar.gz # Install from an archive
See the pip install
docs for more information.
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.
Last updated 7 months ago.