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.
- to_platform_arch()[source]¶
Convert this DebianArchitecture to a platform string.
- Returns:
str– A string matching what platform.machine() or uname -m would return.
- to_efi_arch()[source]¶
Convert this DebianArchitecture to an EFI firmware string.
- Returns:
str– A string as matched by UKIFY in systemd (see https://github.com/systemd/systemd/blob/main/src/ukify/ukify.py)
Build plans¶
- class craft_platforms.BuildInfo(platform, build_on, build_for, build_base)[source]¶
Platform build information.
- Parameters:
platform (
str)build_on (
DebianArchitecture)build_for (
DebianArchitecture|Literal['all'])build_base (
DistroBase)
- build_on¶
Type:
DebianArchitectureThe architecture to build on.
- build_for¶
Type:
Union[DebianArchitecture,Literal['all']]The architecture to build for.
- build_base¶
Type:
DistroBaseThe base to build on.
- craft_platforms.get_platforms_build_plan(base, platforms, build_base=None, *, allow_all_and_architecture_dependent=False)[source]¶
Generate the build plan for a platforms-based artifact.
- Parameters:
base (
str|DistroBase) – The target baseplatforms (
Dict[DebianArchitecture|str,PlatformDict|None]) – A dictionary of the platforms.build_base (
str|None, default:None) – The build base, if declared.allow_all_and_architecture_dependent (
bool, default:False) – whether to allow architecture-dependent platforms and architecture-independent platforms to coexist. This does not change the fact that only one architecture-independent platform can exist.
- Return type:
- craft_platforms.get_build_plan(app, *, project_data, strict_platform_names=False, allow_app_characters=False)[source]¶
Get a build plan for a given application.
- Parameters:
app (
str) – The name of the application (e.g. snapcraft, charmcraft, rockcraft)project_data (
Dict[str,Any]) – The raw dictionary of the project’s YAML file. Normally this is what’s output fromyaml.safe_load().strict_platform_names (
bool, default:False) – Whether to strictly validate all platform names.allow_app_characters (
bool, default:False) – Whether platform name validation allows characters that are reserved for use by applications.
- Returns:
Iterable[BuildInfo] – An iterable containing each possible BuildInfo for this file.- Raises:
InvalidPlatformNameError if strict validation is turned on and a platform name is incorrect.
This function is an abstraction layer over the general build planners, taking the application’s name and its raw data and returning an exhaustive build plan for the given project for that application. This allows craft-platforms to be used in a forward-compatible manner as it adds more logic around selecting build planners or special behaviour for more apps.
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.
- 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.