The lifecycle manager

The lifecycle manager holds information about the parts specification and the project state, and coordinates planning and execution of actions required to run steps for a given set of parts.

class craft_parts.LifecycleManager(all_parts, *, application_name, cache_dir, work_dir='.', arch='', base='', parallel_build_count=1, application_package_name=None, ignore_local_sources=None, extra_build_packages=None, **custom_args)[source]

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.

  • 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’s yaml.load.

  • application_name (str) – A unique non-empty identifier for the application using Craft Parts. The application name is used as a prefix to environment variables set during step execution. Valid application names contain upper and lower case letters, underscores or numbers, and must start with a letter.

  • cache_dir (Union[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 (Union[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) – 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.

  • custom_args – Any additional arguments that will be passed directly to callbacks.


Return a context manager for action execution.

Return type


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.

Para 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.

  • step (Step) –

Return type


plan(target_step, part_names=None)[source]

Obtain the list of actions to be executed given the target step and parts.

  • 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.

  • update – Refresh the list of available packages.

Return type



The list of Action objects that should be executed in order to reach the target step for the specified parts.

property project_info: craft_parts.infos.ProjectInfo

Obtain information about this project.

Return type



Update the available packages list.

The list of available packages should be updated before planning the sequence of actions to take. To ensure consistency between the scenarios, it shouldn’t be updated between planning and execution.

Return type



Reload the ephemeral state from disk.

Return type