craft_parts.utils.path_utils module

Utility functions for paths.

class craft_parts.utils.path_utils.PartitionPathPair(partition: Optional[str], path: Union[PurePath, str])[source]

Bases: tuple

A pair containing a partition name and a path.

partition: Optional[str]

Alias for field number 0

path: Union[PurePath, str]

Alias for field number 1


Break a partition path into the partition and the child path.

If the path begins with a partition, that is used. Otherwise, the default partition is used. If partitions are not enabled, the partition will be None.


path (TypeVar(FlexiblePath, PurePath, str)) – The filepath to parse.

Return type:



A tuple of (partition, filepath)


Get a filepath compatible with the partitions feature.

If the filepath begins with a partition, then the parentheses are stripped from the the partition. For example, (default)/file is converted to default/file.

If the filepath does not begin with a partition, the default partition is prepended. For example, file is converted to default/file.


path (TypeVar(FlexiblePath, PurePath, str)) – The filepath to modify.

Return type:

TypeVar(FlexiblePath, PurePath, str)


A filepath that is compatible with the partitions feature.