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.go_use_plugin module
- craft_parts.plugins.java_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.poetry_plugin module
- craft_parts.plugins.properties module
- craft_parts.plugins.python_plugin module
- craft_parts.plugins.qmake_plugin module
- craft_parts.plugins.rust_plugin module
RustPlugin
RustPluginEnvironmentValidator
RustPluginProperties
RustPluginProperties.after
RustPluginProperties.model_config
RustPluginProperties.plugin
RustPluginProperties.rust_cargo_parameters
RustPluginProperties.rust_channel
RustPluginProperties.rust_features
RustPluginProperties.rust_ignore_toolchain_file
RustPluginProperties.rust_inherit_ldflags
RustPluginProperties.rust_no_default_features
RustPluginProperties.rust_path
RustPluginProperties.rust_use_global_lto
RustPluginProperties.source
RustPluginProperties.validate_rust_channel()
- craft_parts.plugins.scons_plugin module
- craft_parts.plugins.uv_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 (
list
[str
] |None
) – 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.PluginProperties(**data)[source]¶
Bases:
BaseModel
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
]
- 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].
- classmethod model_properties(cls)[source]¶
Get the properties for this model from the JSON schema.
- Return type:
dict
[str
,dict
[str
,Any
]]
-
plugin:
str
¶
-
source:
str
|None
¶
- 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.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
]]
- craft_parts.plugins.register(plugins)[source]¶
Register part handler plugins.
- Parameters:
plugins (
dict
[str
,type
[Plugin
]]) – a dictionary where the keys are plugin names and values are plugin classes. Valid plugins must subclass class:Plugin.- Return type:
None