Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

rez-python-api

FreeNo executable scriptsNot checked

Rez Python API — ResolvedContext construction and inspection, Package/Variant objects, programmatic resolves, .rxt context serialisation and deserialisation…

loonghaoby loonghao346 installs in other catalogs

About this skill

Rez Python API

One-sentence summary: ResolvedContext is the whole product — build one from a list of request strings, read the result off success, resolved_packages and get_environ(), persist it with save() / load(), and only open a shell through execute_shell() when you really need one.

Skill scope: embedding rez in Python. For the CLI equivalents see rez-cli; for solver internals see rez-resolve; for a context used as a deliverable artifact see rez-suites-bundles.

Before you embed rez

Two warnings straight from upstream docs/source/api.rst, and both change the design of a tool:

  • There are no compatibility guarantees between rez versions. Pin the rez you import, the same way the CLI lanes in this repository pin REZ_VERSION.
  • Config is read once, at first import. The Python API cannot reread configuration files or switch to a different REZ_CONFIG_FILE afterwards. A tool that has to change config mid-run must shell out to the CLI instead.

Confirm what you are actually about to import before you trust any of the code below:

rez-status

Module entry points

Module What it holds
rez.resolved_context ResolvedContext — a resolve, and everything you do with one
rez.packages Package, Variant, iter_packages, get_package, get_variant, get_latest_package_from_string
rez.config config — the merged, live settings object
rez.resolver, rez.solver Resolver, ResolverStatus, the solver itself
rez.suite Suite — see rez-suites-bundles
rez.bundle_context bundle_context — see rez-suites-bundles
rez.pip pip_install_package — see rez-pip-integration
rez.developer_package build a package from source in-process
rez.package_repository, rez.package_resources repositories and the resources they hand out
rez.version Version, VersionRange, Requirement, RequirementList, VersionError
rez.exceptions every rez error type; all of them derive from RezError
rez.wrapper the module behind the main console script

Constructing a context

from rez.resolved_context import ResolvedContext

# Requests are plain strings, exactly what you would pass to rez-env.
context = ResolvedContext(["foo-1", "bar"])

if not context.success:
    raise SystemExit(context.failure_description)

ResolvedContext(requests, ...) takes the request list positionally. The arguments worth knowing:

Argument Meaning
verbosity 0, 1 or 2 — the same levels rez-env -v gives you
timestamp epoch time; ignore packages released after it
building / testing resolve as if for rez-build / rez-test
caching None defers to the resolve_caching setting; False bypasses caches
package_paths override packages_path for this resolve only
package_filter a PackageFilterList; rez.package_filter.no_filter removes filtering
add_implicit_packages append the implicit_packages (default True)
max_fails / time_limit stop after N failures / after N seconds

Set verbosity=1 before reaching for a debugger: the solver trace is the same one rez-env -v prints.

Reading the result

context.status                    # ResolverStatus.solved | .failed | .aborted | .pending
context.success                   # True when status is solved
context.failure_description       # why it failed, when it did
context.requested_packages()      # [Requirement, ...] — the request; implicits only if include_implicit=True
context.resolved_packages         # [Variant, ...] — what the solver picked
context.resolved_ephemerals       # resolved ephemeral (implicit-ish) packages
context.get_resolve_as_exact_requests()   # ['foo==1.1.0', ...] — pin the resolve down
context.get_environ()             # dict: the environment the context would produce
context.get_tools()               # {tool_name: (Variant, [alias, ...])}
context.which("foo")              # absolute path to a tool, or None
context.get_resolved_package("foo")       # the Variant, or None
context.print_info(source_order=True)     # the rez-context --so view, on stdout

resolved_packages yields Variant objects, not Package objects. A Package is a family; a Variant is one resolved member of it, with .name, .version, .qualified_name, .root, .requires, .tools and .data on it. Reach for get_resolved_package(name) when you want one package out of a resolve, and get_environ() when you want the environment without running anything.

Context files (.rxt)

A context serialises to a .rxt file, which is how a resolve becomes something you can hand to another process, another machine, or another day:

context.save("context.rxt")                # write it
same = ResolvedContext.load("context.rxt") # read it back

# Or keep it in memory:
from io import StringIO
buf = String
Full SKILL.md on ClawHub

Install rez-python-api in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

FAQ

What does the rez-python-api skill do?

Rez Python API — ResolvedContext construction and inspection, Package/Variant objects, programmatic resolves, .rxt context serialisation and deserialisation, running commands inside a context, and the module entry points (rez.resolved_context, rez.packages, rez.config, rez.pip, rez.suite, rez.bundle_context). Use when the user wants to drive rez from Python instead of the CLI, or asks what a context object actually holds. Covers Rez 3.4.0.

How do I install the rez-python-api skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the rez-python-api skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare rez-python-api with