craft_providers.provider module

Abstract base class for Providers.

The Provider, LXDProvider, and MultipassProvider classes are not stable and are likely to change. These classes will be stable and recommended for use in the release of craft-providers 2.0.

class craft_providers.provider.Provider[source]

Bases: abc.ABC

Build environment provider.

clean_project_environments(*, instance_name)[source]

Clean the provider environment.

Parameters

instance_name (str) – name of the instance to clean

Return type

None

abstract create_environment(*, instance_name)[source]

Create a bare environment for specified base.

No initializing, launching, or cleaning up of the environment occurs.

Parameters

instance_name (str) – name of the instance to create

Return type

Executor

abstract classmethod ensure_provider_is_available()[source]

Ensure provider is available, prompting the user to install it if required.

Raises

ProviderError – if provider is not available.

Return type

None

abstract classmethod is_provider_installed()[source]

Check if provider is installed.

Return type

bool

Returns

True if installed.

abstract launched_environment(*, project_name, project_path, base_configuration, build_base, instance_name)[source]

Configure and launch environment for specified base.

When this method loses context, all directories are unmounted and the environment is stopped. For more control of environment setup and teardown, use create_environment() instead.

Parameters
  • project_name (str) – Name of project.

  • project_path (Path) – Path to project.

  • base_configuration (Base) – Base configuration to apply to instance.

  • build_base (str) – Base to build from.

  • instance_name (str) – Name of the instance to launch.

Return type

Generator[Executor, None, None]