ocebuild.sources.binary
#
Binary helper functions.
Module Contents#
Functions#
|
Gets a platform-dependent extension for vendored binaries. |
|
Gets a digest for a file or directory. |
|
Gets a digest for a stream. |
|
Wraps a binary and returns stdout. |
- ocebuild.sources.binary.get_binary_ext(platform: Literal[Windows, Darwin, Linux] = system()) str [source]#
Gets a platform-dependent extension for vendored binaries.
- ocebuild.sources.binary.get_digest(filepath, algorithm=sha256) str [source]#
Gets a digest for a file or directory.
- Parameters:
filepath – The path to the file or directory.
algorithm – The hashlib algorithm to use. Defaults to SHA256.
- Returns:
A hex digest of the file or directory.
- ocebuild.sources.binary.get_stream_digest(stream, algorithm=sha256) str [source]#
Gets a digest for a stream.
- Parameters:
stream – The stream to read.
algorithm – The hashlib algorithm to use. Defaults to SHA256.
- Returns:
A hex digest of the stream.
- ocebuild.sources.binary.wrap_binary(args: List[str], binary_path: str, persist: bool = True) str [source]#
Wraps a binary and returns stdout.
- Parameters:
args – The arguments to pass to the binary.
binary_path – The path to the binary.
persist – Whether to persist the binary on disk.
- Raises:
RuntimeError – If the binary returns a non-zero exit code.
- Returns:
The stdout of the binary.