# ocx_sdk

*module*

Python SDK for [OCX](https://github.com/ocx-sh/ocx).

`ocx-sdk` drives the ocx binary rather than reimplementing it: ocx owns
resolution, verification, and the identifier grammar, and this package gives
you typed, CWD-independent handles over the commands it exposes.

```python
from ocx_sdk import Ocx, bootstrap

ocx = Ocx(exe=bootstrap.ensure())
project = ocx.project("/srv/build")
project.pull()
project.exec(["task", "verify"])
```

**This module is the API.** Everything listed in `__all__` is the stable
surface; every other module is underscored and package-private, and the one
public submodule is `ocx_sdk.bootstrap`. Reaching into an underscored path
means the next release may move it without notice — pre-1.0, breaking
changes ship without shims.

Start at `Ocx` for the runtime API and `bootstrap.ensure` for provisioning.

[View source](https://github.com/ocx-sh/ocx-sdk-python/blob/main/src/ocx_sdk/__init__.py#L1-L1)

## ocx_sdk.InspectedPackage

*class* · *dataclass*

```python
class InspectedPackage
```

Re-exported from: `ocx_sdk._results`

One package row of `inspect` or `package inspect`.

`name` reads differently per tier: a binding name at the toolchain tier,
the full requested identifier at the package tier.

Everything from `pinned_identifier` down appears only under `--resolve` or
`--closure`. `resolution` and `closure` stay mappings: both are deep trees
whose interesting parts (`closure.surface`, `closure.conflicts`) are still
moving upstream, and modelling a tree we would have to re-model on the next
ocx release buys nothing v0.1 needs.

**Attributes**

- `name` (`str`) — Binding name, or the requested identifier at the package tier.
- `identifier` (`str`) — The identifier as requested.
- `candidates` (`tuple[Candidate, ...]`) — One entry per platform ocx found.
- `pinned_identifier` (`str | None`) — `--resolve`: the identifier with its digest.
- `pinned_digest` (`str | None`) — `--resolve`: the digest alone.
- `platform` (`Mapping[str, Any] | None`) — `--resolve`: the resolved platform object.
- `metadata` (`Mapping[str, Any] | None`) — `--resolve`: the package's `metadata.json`.
- `layers` (`tuple[Mapping[str, Any], ...]`) — `--resolve`: the layer descriptors.
- `resolution` (`Mapping[str, Any] | None`) — `--resolve`: the pin and the walk that produced it.
- `closure` (`Mapping[str, Any] | None`) — `--closure`: dependencies, surface, and conflicts.

[View source](https://github.com/ocx-sh/ocx-sdk-python/blob/main/src/ocx_sdk/_results.py#L785-L841)

### ocx_sdk.InspectedPackage.identifier

*attribute* · *instance attribute*

```python
identifier: str
```

[View source](https://github.com/ocx-sh/ocx-sdk-python/blob/main/src/ocx_sdk/_results.py#L812-L812)

### ocx_sdk.InspectedPackage.layers

*attribute* · *class attribute* · *instance attribute*

```python
layers: tuple[Mapping[str, Any], ...] = ()
```

[View source](https://github.com/ocx-sh/ocx-sdk-python/blob/main/src/ocx_sdk/_results.py#L818-L818)

### ocx_sdk.InspectedPackage.ref

*property*

```python
ref: PackageRef
```

The pinned identifier when resolved, else the requested one.

[View source](https://github.com/ocx-sh/ocx-sdk-python/blob/main/src/ocx_sdk/_results.py#L823-L825)

### ocx_sdk.InspectedPackage.from_dict

*method* · *classmethod*

```python
def from_dict(data: Mapping[str, Any]) -> InspectedPackage
```

Build from one decoded entry of the `packages` array.

[View source](https://github.com/ocx-sh/ocx-sdk-python/blob/main/src/ocx_sdk/_results.py#L827-L841)

## ocx_sdk.InstallReport

*class* · *dataclass*

```python
class InstallReport
```

Re-exported from: `ocx_sdk._results`

`ocx package install` and `ocx package select` — the same keyed object.

Keys are the identifiers **as given**; the values carry the pinned form.
That asymmetry is the point: a caller can look up what it asked for
without knowing what it resolved to.

**Attributes**

- `packages` (`Mapping[str, InstalledPackage]`) — Requested identifier to what got installed.

[View source](https://github.com/ocx-sh/ocx-sdk-python/blob/main/src/ocx_sdk/_results.py#L1205-L1224)

### ocx_sdk.InstallReport.packages

*attribute* · *class attribute* · *instance attribute*

```python
packages: Mapping[str, InstalledPackage] = _EMPTY
```

[View source](https://github.com/ocx-sh/ocx-sdk-python/blob/main/src/ocx_sdk/_results.py#L1217-L1217)

### ocx_sdk.InstallReport.from_json

*method* · *classmethod*

```python
def from_json(raw: str) -> InstallReport
```

Parse `ocx --format json package install` (or `select`) output.

[View source](https://github.com/ocx-sh/ocx-sdk-python/blob/main/src/ocx_sdk/_results.py#L1219-L1224)
