craft_parts.executor package

Submodules

Module contents

The action executor.

class craft_parts.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 (Action | list[Action]) – An Action object or list of Action objects specifying steps to execute.

  • stdout (TextIO | int | None)

  • stderr (TextIO | int | None)

Raises:

InvalidActionException – If the action parameters are invalid.

Return type:

None

class craft_parts.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 (list[str] | None) – Additional packages to install on the host system.

  • extra_build_snaps (list[str] | None) – Additional snaps to install on the host system.

  • ignore_patterns (list[str] | None) – File patterns to ignore when pulling local sources.

  • base_layer_dir (Path | None)

  • base_layer_hash (LayerHash | None)

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 (list[str] | None) – 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 (Action | list[Action]) – An Action object or list of Action objects specifying steps to execute.

  • stdout (TextIO | int | None)

  • stderr (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

class craft_parts.executor.Fileset(entries, *, name='', default_partition='default')[source]

Bases: object

A class that represents a list of filepath strings to include or exclude.

Filepaths to include do not begin with a hyphen. Filepaths to exclude begin with a hyphen.

Parameters:
  • entries (list[str])

  • name (str)

  • default_partition (str)

combine(other)[source]

Combine the entries in this fileset with entries from another fileset.

Parameters:

other (Fileset) – The fileset to combine with.

Return type:

None

property entries: list[str]

Return the list of entries in this fileset.

property excludes: list[str]

Return the list of files to be excluded.

property includes: list[str]

Return the list of files to be included.

property name: str

Return the fileset name.

remove(item)[source]

Remove this entry from the list of files.

Parameters:

item (str) – The item to remove.

Return type:

None

craft_parts.executor.expand_environment(data, *, info, skip=None)[source]

Replace global variables with their values.

Global variables are defined by craft-parts and are the subset of the CRAFT_* step execution environment variables that don’t depend on the part or step being executed. The list of global variables include CRAFT_ARCH_TRIPLET, CRAFT_PROJECT_DIR, CRAFT_STAGE and CRAFT_PRIME. Additional global variables can be defined by the application using craft-parts.

Parameters:
  • data (dict[str, Any]) – A dictionary whose values will have variable names expanded.

  • info (ProjectInfo) – The project information.

  • skip (list[str] | None) – Keys to skip when performing expansion.

Return type:

None