craft_parts.plugins package¶
Submodules¶
- craft_parts.plugins.ant_plugin module
- craft_parts.plugins.autotools_plugin module
- craft_parts.plugins.base module
- craft_parts.plugins.cmake_plugin module
- craft_parts.plugins.dotnet_plugin module
- craft_parts.plugins.dump_plugin module
- craft_parts.plugins.go_plugin module
- craft_parts.plugins.make_plugin module
- craft_parts.plugins.maven_plugin module
- craft_parts.plugins.meson_plugin module
- craft_parts.plugins.nil_plugin module
- craft_parts.plugins.npm_plugin module
- craft_parts.plugins.plugins module
- craft_parts.plugins.properties module
- craft_parts.plugins.python_plugin module
- craft_parts.plugins.rust_plugin module
- craft_parts.plugins.scons_plugin module
- craft_parts.plugins.validator module
Module contents¶
Craft Parts plugins subsystem.
- class craft_parts.plugins.Plugin(*, properties, part_info)[source]¶
Bases:
ABC
The base class for plugins.
- Variables:
properties_class – The plugin properties class.
validator_class – The plugin environment validator class.
- Parameters:
part_info (
PartInfo
) – The part information for the applicable part.properties (
PluginProperties
) – Part-defined properties.
- abstract get_build_commands()[source]¶
Return a list of commands to run during the build step.
- Return type:
List
[str
]
- abstract get_build_environment()[source]¶
Return a dictionary with the environment to use in the build step.
- Return type:
Dict
[str
,str
]
- abstract get_build_packages()[source]¶
Return a set of required packages to install in the build environment.
- Return type:
Set
[str
]
- abstract get_build_snaps()[source]¶
Return a set of required snaps to install in the build environment.
- Return type:
Set
[str
]
- classmethod get_out_of_source_build()[source]¶
Return whether the plugin performs out-of-source-tree builds.
- Return type:
bool
- get_pull_commands()[source]¶
Return the commands to retrieve dependencies during the pull step.
- Return type:
List
[str
]
- properties_class: Type[PluginProperties]¶
- set_action_properties(action_properties)[source]¶
Store a copy of the given action properties.
- Parameters:
action_properties (
ActionProperties
) – The properties to store.- Return type:
None
- supports_strict_mode = False¶
Plugins that can run in ‘strict’ mode must set this classvar to True.
- validator_class¶
alias of
PluginEnvironmentValidator
- class craft_parts.plugins.PluginEnvironmentValidator(*, part_name, env, properties)[source]¶
Bases:
object
Base class for plugin environment validators.
Plugins may require certain environment elements to be present in order to build a part, regardless of how these elements were installed on the system. For example, a compiler may have been installed from a deb package, a snap, built from sources or even built by a different part. Plugin environment validators allow a plugin to ensure its execution environment is correct before building a part.
- Parameters:
part_name (
str
) – The part whose build environment is being validated.env (
str
) – A string containing the build step environment setup.properties (
PluginProperties
) –
- validate_dependency(dependency, plugin_name, part_dependencies, argument='--version')[source]¶
Validate that the environment has a required dependency.
<dependency-name> –version is executed to confirm the dependency is valid.
- Parameters:
dependency (
str
) – name of the dependency to validate.plugin_name (
str
) – used to generate the part name that would satisfy the dependency.part_dependencies (
Optional
[List
[str
]]) – A list of the parts this part depends on.argument (
str
) – argument to call with the dependency. Default is –version.
- Raises:
PluginEnvironmentValidationError – If the environment is invalid.
- Return type:
str
- Returns:
output from executed dependency
- validate_environment(*, part_dependencies=None)[source]¶
Ensure the plugin execution environment is valid.
The environment is verified twice: during the execution prologue after build packages and snaps are installed (to provide an early error message if the environment is invalid), and before running the build step for the part. During the prologue validation the environment may be incomplete, so we pass a list of the part dependencies as a hint of which parts may be used to build the environment.
- Parameters:
part_dependencies (
Optional
[List
[str
]]) – A list of the parts this part depends on, so the validator can check if the required environment elements are supplied by another part when the method is called from the execution prologue. If the validation fails and list is empty, the error is final (the missing elements can’t be supplied by a different part). The plugin may require a specific part name as a hint that the part will attempt to supply missing environment elements.- Raises:
PluginEnvironmentValidationError – If the environment is invalid.
- Return type:
None
- class craft_parts.plugins.PluginModel(**data)[source]¶
Bases:
PluginPropertiesModel
Model for plugins using pydantic validation.
Plugins with configuration properties can use pydantic validation to unmarshal data from part specs. In this case, extract plugin-specific properties using the
extract_plugin_properties()
helper.- Parameters:
data (
Any
) –
- class craft_parts.plugins.PluginProperties(**data)[source]¶
Bases:
PluginPropertiesModel
Options specific to a plugin.
PluginProperties should be subclassed into plugin-specific property classes and populated from a dictionary containing part properties.
By default all plugin properties will be compared to check if the build step is dirty. This can be overridden in each plugin if needed.
- Parameters:
data (
Any
) –
- classmethod get_build_properties()[source]¶
Obtain the list of properties affecting the build stage.
- Return type:
List
[str
]
- classmethod get_pull_properties()[source]¶
Obtain the list of properties affecting the pull stage.
- Return type:
List
[str
]
- marshal()[source]¶
Obtain a dictionary containing the plugin properties.
- Return type:
Dict
[str
,Any
]
- craft_parts.plugins.extract_part_properties(data, *, plugin_name)[source]¶
Get common part properties without plugin-specific entries.
- Parameters:
data (
Dict
[str
,Any
]) – A dictionary containing all part properties.plugin_name (
str
) – The name of the plugin.
- Return type:
Dict
[str
,Any
]- Returns:
A dictionary containing only common part properties.
- craft_parts.plugins.extract_plugin_properties(data, *, plugin_name, required=None)[source]¶
Obtain plugin-specifc entries from part properties.
- Parameters:
data (
Dict
[str
,Any
]) – A dictionary containing all part properties.plugin_name (
str
) –required (
Optional
[List
[str
]]) –
- Plugin_name:
The name of the plugin.
- Return type:
Dict
[str
,Any
]- Returns:
A dictionary with plugin properties.
- craft_parts.plugins.get_plugin(*, part, part_info, properties)[source]¶
Obtain a plugin instance for the specified part.
- Parameters:
part (
Part
) – The part requesting the plugin.part_info (
PartInfo
) – The part information data.properties (
PluginProperties
) – The plugin properties.
- Return type:
- Returns:
The plugin instance.
- craft_parts.plugins.get_plugin_class(name)[source]¶
Obtain a plugin class given the name.
- Parameters:
name (
str
) – The plugin name.- Return type:
Type
[Plugin
]- Returns:
The plugin class.
- Raises:
ValueError – If the plugin name is invalid.
- craft_parts.plugins.get_registered_plugins()[source]¶
Return the list of currently registered plugins.
- Return type:
Dict
[str
,Type
[Plugin
]]