Skip to content
ocx
install

Project (2 of 6)

Projectclassdataclass#

Re-exported from ocx_sdk._clientView source

execmethod#

def exec(argv: Sequence[str], *, names: Iterable[str] = (), groups: Iterable[str] = (), clean: bool = False, env: Mapping[str, EnvValue] | None = None, lazy_mode: LazyMode | None = None, pinned: bool | None = None, records_dir: str | Path | None = None, records_name: str | None = None, capture: bool = True, check: bool = True, timeout: MaybeTimeout = UNSET) -> CommandResult

Run a command inside the project’s composed environment.

The child’s exit code comes back byte for byte, so check=False is how you inspect a failing build instead of catching an exception. Child processes are never retried.

Parameters

NameTypeDefaultDescription
argvSequence[str]requiredThe command and its arguments. Must not be empty.
namesIterable[str]()Bindings to compose. Omitted composes the default set.
groupsIterable[str]()Groups to compose.
cleanboolFalseStrip the ambient parent environment before composing.
envMapping[str, EnvValue] | NoneNoneExtra [env] entries for this call.
lazy_modeLazyMode | NoneNoneWhen content downloads — now, or on first use.
pinnedbool | NoneNoneResolve through the rendered toolchain’s pinned digests rather than following its links — ocx’s --pinned / --no-pinned. None leaves the choice to ocx.toml, then OCX_TOOLCHAIN_PINNED, then ocx’s default.
records_dirstr | Path | NoneNoneWrite an execution record — the resolved closure and executable, captured just before the child starts — under this directory, which must already exist (ocx warns and skips the record otherwise). None leaves it to [records] dir and OCX_RECORDS_DIR; with none of the three, no record.
records_namestr | NoneNoneThe record’s filename template, over {time}, {host}, {pid} and {rand}. None leaves it to [records] name and OCX_RECORDS_NAME.
captureboolTruePipe and capture both streams. False inherits stdio and forwards SIGINT to the child.
checkboolTrueRaise on a non-zero child exit instead of returning it.
timeoutMaybeTimeoutUNSETSeconds for the whole run. Omitted takes the config’s.

Returns

CommandResult
The child’s exit code and, under capture, its output.

Raises

ValueError
argv is empty — ocx requires a command after --.
OcxProcessError
The child exited non-zero under check.
OcxTimeoutError
The timeout expired.

with_configmethod#

def with_config(**overrides: Unpack[ConfigOverrides]) -> Project

Derive a project handle with some configuration fields replaced.

Parameters

NameTypeDefaultDescription
**overridesUnpack[ConfigOverrides]{}OcxConfig field names and their new values, as ConfigOverrides spells them.

Returns

Project
The same project, seen through a derived Ocx.

Raises

TypeError
An override names no OcxConfig field.