Skip to content
ocx
install

Ocx, Project

Ocxclass#

Re-exported from ocx_sdk._clientView source

projectmethod#

def project(path: str | Path) -> Project

Return a project-tier handle rooted at path.

The path is made absolute immediately, so the handle keeps targeting the same project no matter what the working directory does later.

ocx’s --project names the project file, the way Cargo’s --manifest-path does, and accepts any filename. A directory is the obvious thing to pass and the common case, so it is resolved to the ocx.toml inside it.

A path that does not exist yet — which is every path init() is called on — is read by its name: a .toml suffix means the file, anything else means the directory. Guessing “file” there would make project('/srv/build').init() write /srv/ocx.toml, one level above where the caller pointed.

Parameters

NameTypeDescription
pathstr | PathThe project directory, or the project file directly.

Returns

Project
A handle whose every call carries --project <file>.

versionmethod#

def version(timeout: MaybeTimeout = UNSET, retry: MaybeRetry = UNSET) -> str

Return the binary’s version, as ocx version prints it.

Reads the plain output — a bare semver line — which is ocx’s documented stable script contract and the recorded exception to the --format json pinning rule. This call is the compatibility probe itself, so it never triggers the gate and never raises VersionCompatError: asking an unsupported binary what it is has to work. The richer JSON envelope is available through VersionInfo.from_json(ocx.invoke(["--format", "json", "version"]).stdout).

Parameters

NameTypeDefaultDescription
timeoutMaybeTimeoutUNSETSeconds per attempt. Omitted takes the config’s.
retryMaybeRetryUNSETRetry policy. None opts out; omitted takes the config’s.

Returns

str
The version string, whitespace stripped.

Projectclassdataclass#

Re-exported from ocx_sdk._clientView source
class Project(_runner: _Runner, path: Path)

A project-tier handle: every call carries --project <file>.

Obtained from Ocx.project(path), never constructed directly. Because the path travels explicitly on every call, no method depends on the working directory, and an ambient OCX_PROJECT can never retarget one. init is the exception, and only because ocx’s is: it takes no flags and writes into the working directory, so the handle sets that instead.

Attributes

NameTypeDescription
pathPathThe absolute project file — the ocx.toml itself, which is what ocx’s --project names.
session_configOcxConfigThe OcxConfig every call spawns under.