craft_parts.plugins.python_v2.python_plugin module¶
Version 2 of the Python plugin.
- class craft_parts.plugins.python_v2.python_plugin.PythonPlugin(*, properties, part_info)¶
Bases:
PluginPython plugin, version 2.
Unlike the original Python plugin, this one does not require the creation of virtual environments to work. Instead, it uses pip’s support for both a) installing directly into the user’s base dir and b) using a Python interpreter that is not the one running pip initially. This allows lighter payloads as the -venv package is not required, and interacts well with usrmerged directories.
The downside is that the payload generated by the plugin assumes that the primed contents will include the Python interpreter; if this is not the case, the runtime will need to add the payload to Python’s path (e.g. via PYTHONPATH).
- Parameters:
properties (
PluginProperties)part_info (
PartInfo)
- get_build_commands()¶
Return a list of commands to run during the build step.
- get_build_environment()¶
Return a dictionary with the environment to use in the build step.
- get_build_packages()¶
Return a set of required packages to install in the build environment.
- get_build_snaps()¶
Return a set of required snaps to install in the build environment.
- properties_class¶
alias of
PythonPluginProperties
- class craft_parts.plugins.python_v2.python_plugin.PythonPluginProperties(**data)¶
Bases:
PluginPropertiesThe part properties used by the python plugin.
- Parameters:
data (
Any)
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function PluginProperties.<lambda>>, 'extra': 'forbid', 'frozen': True, 'validate_assignment': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
-
python_requirements:
list[str]¶ List of paths to requirements files.
Use this key when dependencies must be installed from one or more explicit requirements files, such as
requirements.txt. The plugin does not automatically select a requirements file from the source tree; each file must be listed here.A part does not need this key when its dependencies are already declared by the project metadata used during package installation. For example, when the source contains a
setup.pyorpyproject.tomlfile, the plugin installs the project and pip resolves the dependencies declared by the package itself. That metadata may also come from configuration files such assetup.cfg.