craft_parts.lifecycle_manager module¶
The parts lifecycle manager.
- class craft_parts.lifecycle_manager.LifecycleManager(all_parts, *, application_name, cache_dir, work_dir='.', arch='', base='', project_name=None, parallel_build_count=1, application_package_name=None, ignore_local_sources=None, extra_build_packages=None, extra_build_snaps=None, track_stage_packages=False, strict_mode=False, base_layer_dir=None, base_layer_hash=None, project_vars_part_name=None, project_vars=None, partitions=None, **custom_args)[source]¶
Bases:
object
Coordinate the planning and execution of the parts lifecycle.
The lifecycle manager determines the list of actions that needs be executed in order to obtain a tree of installed files from the specification on how to process its parts, and provides a mechanism to execute each of these actions.
- Parameters:
all_parts (
dict
[str
,Any
]) – A dictionary containing the parts specification according to the parts schema. The format is compatible with the output generated by PyYAML’syaml.load
.application_name (
str
) – A unique non-empty identifier for the application using Craft Parts. Valid application names contain upper and lower case letters, underscores or numbers, and must start with a letter.project_name (
Optional
[str
]) – name of the project being built.cache_dir (
Path
|str
) – The path to store cached packages and files. If not specified, a directory under the application name entry in the XDG base directory will be used.work_dir (
Path
|str
) – The toplevel directory for work directories. The current directory will be used if none is specified.arch (
str
) – The architecture to build for. Defaults to the host system architecture.base (
str
) – [deprecated] The system base the project being processed will run on. Defaults to the system where Craft Parts is being executed.parallel_build_count (
int
) – The maximum number of concurrent jobs to be used to build each part of this project.application_package_name (
Optional
[str
]) – The name of the application package, if required by the package manager used by the platform. Defaults to the application name.ignore_local_sources (
Optional
[list
[str
]]) – A list of local source patterns to ignore.extra_build_packages (
Optional
[list
[str
]]) – A list of additional build packages to install.extra_build_snaps (
Optional
[list
[str
]]) – A list of additional build snaps to install.track_stage_packages (
bool
) – Add primed stage packages to the prime state.strict_mode (
bool
) – Only allow plugins capable of building in strict mode.base_layer_dir (
Optional
[Path
]) – The path to the overlay base layer, if using overlays.base_layer_hash (
Optional
[bytes
]) – The validation hash of the overlay base image, if using overlays. The validation hash should be constant for a given image, and should change if a different base image is used.project_vars_part_name (
Optional
[str
]) – Project variables can only be set in the part matching this name.project_vars (
Optional
[dict
[str
,str
]]) – A dictionary containing project variables.partitions (
Optional
[list
[str
]]) – A list of partitions to use when the partitions feature is enabled. The first partition must be “default”. Partitions may have an optional namespace prefix separated by a forward slash. Partition names must contain one or more lowercase alphanumeric characters or hyphens (“-“), and may not begin or end with a hyphen. Namespace names must consist of only lowercase alphanumeric characters.custom_args (
Any
) – Any additional arguments that will be passed directly to callbacks.
- clean(step=Step.PULL, *, part_names=None)[source]¶
Clean the specified step and parts.
Cleaning a step removes its state and all artifacts generated in that step and subsequent steps for the specified parts.
- Parameters:
step (
Step
) – The step to clean. If not specified, all steps will be cleaned.part_names (
Optional
[list
[str
]]) – The list of part names to clean. If not specified, all parts will be cleaned and work directories will be removed.
- Return type:
None
- get_primed_stage_packages(*, part_name)[source]¶
Return the list of primed stage packages.
- Parameters:
part_name (
str
) – The name of the part to get primed stage packages from.- Return type:
list
[str
] |None
- Returns:
The sorted list of primed stage packages, or None if no state found.
- get_pull_assets(*, part_name)[source]¶
Return the part’s pull state assets.
- Parameters:
part_name (
str
) – The name of the part to get assets from.- Return type:
dict
[str
,Any
] |None
- Returns:
The dictionary of the part’s pull assets, or None if no state found.
- plan(target_step, part_names=None, *, rerun=False)[source]¶
Obtain the list of actions to be executed given the target step and parts.
- Parameters:
target_step (
Step
) – The final step we want to reach.part_names (
Optional
[Sequence
[str
]]) – The list of parts to process. If not specified, all parts will be processed.rerun (
bool
)
- Return type:
list
[Action
]- Returns:
The list of
Action
objects that should be executed in order to reach the target step for the specified parts.
- property project_info: ProjectInfo¶
Obtain information about this project.