Tools

A recipe step can need tools, such as a compiler. Steps express this as tool sets: each set names tools that together satisfy the step. The options package defines tool sets for recipe handling. The protocol carries them as ToolSet messages, defined in the tool protocol.

This module converts between the two forms:

from momotor.rpc.proto.tool_pb2 import ToolSet
from momotor.rpc.tools import message_to_toolsets, toolsets_to_message

messages = list(toolsets_to_message([frozenset({'gcc'}), frozenset({'clang'})]))
toolsets = list(message_to_toolsets([ToolSet(tool=['gcc'])]))

messages now holds one ToolSet message per set, and toolsets holds [frozenset({'gcc'})].

API reference

momotor.rpc.tools.message_to_toolsets(toolset_message)

Convert a sequence of ToolSet protocol messages back into tool sets

Parameters:

toolset_message (Sequence[ToolSet] | None) – The ToolSet messages to convert, or None

Return type:

Iterable[frozenset[str]]

Returns:

One frozenset of tool names per message. Nothing is yielded for None or an empty sequence.

momotor.rpc.tools.toolsets_to_message(toolsets)

Convert an iterable of tool sets into ToolSet protocol messages

Parameters:

toolsets (Iterable[Set[str | PathLike | ToolName]]) – The tool sets to convert. Each tool set is an iterable of tool names that together satisfy a step.

Return type:

Iterable[ToolSet]

Returns:

One ToolSet message per tool set