repomatic.deps.uv module¶

Build uv and uvx command lines, and run them.

The leaf of the dependency package: it imports nothing else from it, so the tool runner and the docs builder reach the builders without loading the lock and report machinery. The lock views live in repomatic.deps.lockfile, the cooldown lifecycle in repomatic.deps.cooldown.

repomatic.deps.uv.uv_cmd(subcommand, *, frozen=False, no_project=False, exclude_newer=None)[source]¶

Build a uv <subcommand> command prefix with standard flags.

Always includes --no-progress. Adds --frozen when requested (appropriate for run, export, sync, never for lock). Adds --no-project to skip project discovery entirely, and --exclude-newer to gate a resolution by a cooldown, mirroring uvx_cmd().

Parameters:
  • subcommand (str) – The uv subcommand.

  • frozen (bool) – Add --frozen.

  • no_project (bool) – Add --no-project.

  • exclude_newer (str | None) – The --exclude-newer value, in any form uv accepts. Omitted when empty.

Return type:

list[str]

repomatic.deps.uv.uvx_cmd(exclude_newer=None)[source]¶

Build a uvx command prefix with standard flags.

When exclude_newer is set (a YYYY-MM-DD date), adds --exclude-newer so the isolated resolution honors the minimum-release-age cooldown, gating the tool’s transitive dependencies by upload date.

Return type:

list[str]

repomatic.deps.uv.uv_lock_command(*extra, exclude_newer='', exclude_newer_packages=None)[source]¶

Build a uv lock argv carrying a cooldown window.

The one builder behind every re-lock this package runs with a window (sync-uv-lock, the dep-sources swap, audit --fix, the held-back probe), so none of them can forget the explicit --exclude-newer that keeps CI’s ambient UV_EXCLUDE_NEWER from retiming the lock: see repomatic.deps.cooldown.UvSettings.window. relock() alone runs a plain uv lock.

Parameters:
  • extra (str) – Extra uv lock arguments (--upgrade, --upgrade-package, …), placed before the cooldown flags.

  • exclude_newer (str) – The window, in any form uv accepts. Empty leaves the flag off.

  • exclude_newer_packages (Mapping[str, str] | None) – Package name to its own window, for this run only. A flag on the command line beats the pyproject.toml entry of the same package.

Return type:

list[str]

Returns:

The argv to run, with cwd set to the project directory.

exception repomatic.deps.uv.UvError(returncode, cmd, output=None, stderr=None)[source]¶

Bases: CalledProcessError

A uv command that exited non-zero, carrying what it printed on stderr.

repomatic.deps.uv.run_uv(cmd, *, cwd=None, check=True)[source]¶

Run a uv command and capture its output.

The one runner behind every uv call of this package. The output is captured, never streamed: a resolution summary printed while a progress trail is on screen lands on the trail’s own row. The decoding is pinned to UTF-8, since an SBOM carries package descriptions and author names that the platform default cannot always decode.

Parameters:
  • cmd (Sequence[str]) – The argv, from one of the builders above.

  • cwd (Path | None) – The directory to run in. Defaults to the working directory.

  • check (bool) – Raise on a non-zero exit.

Return type:

CompletedProcess[str]

Returns:

The completed process, stdout and stderr as text.

Raises:

UvError – When the command fails and check is set. Its message carries the command’s stderr. Also when the command cannot start, with no uv on PATH or no cwd, whatever check: the exit status is then 127, the one a shell gives a command it cannot find.

repomatic.deps.uv.relock()[source]¶

Refresh uv.lock after a version bump, and nothing else in it.

A plain uv lock, on purpose. bump-my-version rewrites the project’s version in pyproject.toml but not in uv.lock, and a bump committed without the re-lock leaves the project ahead of its own lock entry: the next uv run --frozen then reinstalls the project, and two nested syncs of a release build can delete a console script the other one is running, a sharing violation on Windows.

uv lock --upgrade would re-resolve every dependency instead. With a "0 day" exclude-newer-package bypass in place, it fast-forwards that dependency across a release still inside its cooldown, on an unreviewed bump pull request. uv sync would leave the lock in a state the sync-uv-lock job rewrites into a redundant follow-up pull request. Dependency upgrades stay the job of sync-uv-lock, in their own pull request.

Raises:

UvError – When uv cannot lock the project.

Return type:

None