Skip to main content

enterprise_ai.packs.build

Source: sdks/python/src/enterprise_ai/packs/build.py. Back to the Python SDK reference index.

note

This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.

Model BuildResult​

Result of build_pack: archive, digest, SBOM, validation report and file digests.

Fields:

NameTypeRequiredDescription
archivePathyesThe .tar.gz pack, base64 encoded (up to 12 MiB of text).
digeststryesSHA-256 of the evidence (commands, recording), at most 100 characters.
sbomdict[str, Any]yesSoftware bill of materials of the pack.
sbom_pathPathyesPath of the written <name>-<version>.spdx.json.
reportPackReportyesValidation report of the pack (PackReport).
filesdict[str, str]yesFiles to import (1 to 200).

BuildResult.to_dict​

to_dict() -> dict[str, Any]

The result as a JSON ready summary.

This element takes no parameter.

Returns: dict[str, Any]. Dict {archive, digest, sbom, files, name, version}: paths as text, files is the number of files.

Functions​

sha256_bytes​

sha256_bytes(data: bytes) -> str

SHA-256 digest of bytes, prefixed with sha256:.

NameTypeDefaultRequiredDescription
databytesyesBytes to hash.

Returns: str. Text sha256:<64 hexadecimal characters>.

source_date_epoch​

source_date_epoch() -> int

Fixed time of the archive entries and of the SBOM, read from the SOURCE_DATE_EPOCH environment variable.

This element takes no parameter.

Returns: int. Unix time in seconds; 0 when the variable is not set.

archive_bytes​

archive_bytes(root: Path) -> tuple[bytes, dict[str, str]]

Build the reproducible gzip tar of the pack in memory: sorted entries, mode 0644 or 0755, owner 0, time SOURCE_DATE_EPOCH.

NameTypeDefaultRequiredDescription
rootPathyesFolder of the pack; files are picked by pack_files.

Returns: tuple[bytes, dict[str, str]]. Tuple (archive bytes, {relative path: sha256:<hex>}).

spdx_sbom​

spdx_sbom(report: PackReport, digest: str, files: dict[str, str]) -> dict[str, Any]

SPDX 2.3 JSON document: the pack package, each file with its SHA-256, and the pinned runtime dependencies.

NameTypeDefaultRequiredDescription
reportPackReportyesValidation report of the pack: name, version, licence and owner come from its manifest; pinned lines of requirements.txt become dependencies.
digeststryesDigest sha256:<hex> of the archive, used in the namespace and checksum of the package.
filesdict[str, str]yesRelative path to sha256:<hex> of every file of the archive.

Returns: dict[str, Any]. SPDX 2.3 document as a dict.

build_pack​

build_pack(path: str | Path, out_dir: str | Path | None = None) -> BuildResult

Validate, then write <name>-<version>.tar.gz and <name>-<version>.spdx.json into out_dir.

NameTypeDefaultRequiredDescription
pathstr | PathyesFolder of the pack to build; an invalid pack raises ValueError listing the errors.
out_dirstr | Path | NoneNonenoOutput folder, created when missing; default dist inside the pack.

Returns: BuildResult. A BuildResult with the archive path, its sha256: digest and the SBOM.

Raises: ValueError.