craft_parts.executor.executor module

Definitions and helpers for the action executor.

class craft_parts.executor.executor.ExecutionContext(*, executor)[source]

Bases: object

A context manager to handle lifecycle action executions.

Parameters:

executor (Executor) –

execute(actions, *, stdout=None, stderr=None)[source]

Execute the specified action or list of actions.

Parameters:
  • actions (Union[Action, List[Action]]) – An Action object or list of Action objects specifying steps to execute.

  • stdout (Union[TextIO, int, None]) –

  • stderr (Union[TextIO, int, None]) –

Raises:

InvalidActionException – If the action parameters are invalid.

Return type:

None

class craft_parts.executor.executor.Executor(*, part_list, project_info, extra_build_packages=None, extra_build_snaps=None, track_stage_packages=False, ignore_patterns=None, base_layer_dir=None, base_layer_hash=None)[source]

Bases: object

Execute lifecycle actions.

The executor takes the part definition and a list of actions to run for a part and step. Action execution is stateless: no information is kept from the execution of previous parts. On-disk state information written after running each action is read by the sequencer before planning a new set of actions.

Parameters:
  • part_list (List[Part]) – The list of parts to process.

  • project_info (ProjectInfo) – Information about this project.

  • track_stage_packages (bool) – Add primed stage packages to the prime state.

  • extra_build_packages (Optional[List[str]]) – Additional packages to install on the host system.

  • extra_build_snaps (Optional[List[str]]) – Additional snaps to install on the host system.

  • ignore_patterns (Optional[List[str]]) – File patterns to ignore when pulling local sources.

  • base_layer_dir (Optional[Path]) –

  • base_layer_hash (Optional[LayerHash]) –

clean(initial_step, *, part_names=None)[source]

Clean the given parts, or all parts if none is specified.

Parameters:
  • initial_step (Step) – The step to clean. More steps may be cleaned as a consequence of cleaning the initial step.

  • part_names (Optional[List[str]]) – A list with names of the parts to clean. If not specified, all parts will be cleaned and work directories will be removed.

Return type:

None

epilogue()[source]

Finish and clean the execution environment.

This method is called after executing lifecycle actions.

Return type:

None

execute(actions, *, stdout=None, stderr=None)[source]

Execute the specified action or list of actions.

Parameters:
  • actions (Union[Action, List[Action]]) – An Action object or list of Action objects specifying steps to execute.

  • stdout (Union[TextIO, int, None]) –

  • stderr (Union[TextIO, int, None]) –

Raises:

InvalidActionException – If the action parameters are invalid.

Return type:

None

prologue()[source]

Prepare the execution environment.

This method is called before executing lifecycle actions.

Return type:

None