Skip to content

_pack

Pack runtime into distributable archive.

Functions

log(*msg, method_name=None, level=logging.INFO)

Log a message with automatic method name detection.

Parameters:

Name Type Description Default
msg str

The message to log

()
method_name str

The name of the method/function. If None, will auto-detect from call stack.

None
level int

Logging level (default: logging.INFO)

INFO
Source code in brmspy/helpers/log.py
def log(*msg: str, method_name: str | None = None, level: int = logging.INFO):
    """
    Log a message with automatic method name detection.

    Parameters
    ----------
    msg : str
        The message to log
    method_name : str, optional
        The name of the method/function. If None, will auto-detect from call stack.
    level : int, optional
        Logging level (default: logging.INFO)
    """
    if method_name is None:
        method_name = _get_caller_name()

    msg_str = " ".join(str(v) for v in msg)

    logger = get_logger()
    logger.log(level, msg_str, extra={"method_name": method_name})

pack_runtime(runtime_root, out_dir, runtime_version)

Create compressed tar archive from runtime directory.

Packages the staged runtime directory into a distributable .tar.gz archive with standardized naming for platform/version identification.

Archive naming format: brmspy-runtime-{runtime_version}-{fingerprint}.tar.gz

Parameters:

Name Type Description Default
runtime_root Path

Path to staged runtime directory (from stage_runtime_tree)

required
out_dir Path

Output directory for archive file

required
runtime_version str

Runtime schema version (e.g., "0.1.0")

required

Returns:

Type Description
Path

Path to created .tar.gz archive file

Source code in brmspy/_build/_pack.py
def pack_runtime(runtime_root: Path, out_dir: Path, runtime_version: str) -> Path:
    """
    Create compressed tar archive from runtime directory.

    Packages the staged runtime directory into a distributable .tar.gz
    archive with standardized naming for platform/version identification.

    Archive naming format:
    brmspy-runtime-{runtime_version}-{fingerprint}.tar.gz

    Parameters
    ----------
    runtime_root : Path
        Path to staged runtime directory (from stage_runtime_tree)
    out_dir : Path
        Output directory for archive file
    runtime_version : str
        Runtime schema version (e.g., "0.1.0")

    Returns
    -------
    Path
        Path to created .tar.gz archive file
    """
    fingerprint = runtime_root.name
    archive_name = f"brmspy-runtime-{runtime_version}-{fingerprint}.tar.gz"
    archive_path = out_dir / archive_name

    out_dir.mkdir(parents=True, exist_ok=True)

    log(f"[tar] Creating archive {archive_path}")
    with tarfile.open(archive_path, "w:gz") as tf:
        # Add the runtime root directory contents under "runtime/"
        tf.add(runtime_root, arcname="runtime")

    return archive_path