Package reference

Architectures

class craft_platforms.DebianArchitecture(value)[source]

A Debian architecture.

classmethod from_machine(arch)[source]

Get a DebianArchitecture value from the given platform arch.

Parameters:

arch (str) – a string containing an architecture as returned by platform.machine()

Returns:

Self – The DebianArchitecture enum value

Raises:

ValueError if the architecture is not a valid Debian architecture.

classmethod from_host()[source]

Get the DebianArchitecture of the running host.

Return type:

Self

to_platform_arch()[source]

Convert this DebianArchitecture to a platform string.

Returns:

str – A string matching what platform.machine() or uname -m would return.

Build plans

class craft_platforms.BuildInfo(platform, build_on, build_for, build_base)[source]

Platform build information.

Parameters:
platform

Type:    str

The platform name.

build_on

Type:    DebianArchitecture

The architecture to build on.

build_for

Type:    Union[DebianArchitecture, Literal['all']]

The architecture to build for.

build_base

Type:    DistroBase

The base to build on.

craft_platforms.get_platforms_build_plan(base, platforms, build_base=None)[source]

Generate the build plan for a platforms-based artefact.

Parameters:
Return type:

Sequence[BuildInfo]

Distributions

class craft_platforms.BaseName(*args, **kwargs)[source]

A protocol for any class that can be used as an OS base.

This protocol exists as a backwards compatibility shim for the language used in craft-providers.

class craft_platforms.DistroBase(distribution, series)[source]

A linux distribution base.

Parameters:
  • distribution (str) –

  • series (str) –

classmethod from_str(base_str)[source]

Parse a distribution string to a DistroBase.

Parameters:

base_str (str) – A distribution string (e.g. “ubuntu@24.04”)

Returns:

Self – A DistroBase of this string.

Raises:

ValueError if the string isn’t of the appropriate format.

classmethod from_linux_distribution(distribution)[source]

Convert a distro package’s LinuxDistribution object to a DistroBase.

Parameters:

distribution (LinuxDistribution) – A LinuxDistribution from the distro package.

Returns:

Self – A matching DistroBase object.

craft_platforms.is_ubuntu_like(distribution=None)[source]

Determine whether the given distribution is Ubuntu or Ubuntu-like.

Parameters:

distribution (Optional[LinuxDistribution], default: None) – Linux distribution info object, or None to use the host system.

Returns:

bool – A boolean noting whether the given distribution is Ubuntu or Ubuntu-like.