Skip to content

uv lock(): support non-quiet output from the .run target #4164

Description

@psalaberria002

Problem

The lock() macro in @rules_python//python/uv:lock.bzl generates a .run target whose shell script hardcodes --no-progress --quiet when invoked via bazel run:

exec '.../uv' 'lock' '--no-python-downloads' '--no-cache' '--project' '.' '--python' '...' '--no-progress' '--quiet' "$@"

This means all uv output is suppressed. Passing --verbose does not work — uv rejects --quiet and --verbose together with an error:

error: the argument '--quiet...' cannot be used with '--verbose...'

Use case

We call bazel run //:uv_lock.run -- --check from a just recipe to verify that uv.lock is consistent with pyproject.toml (a developer workflow check, not a CI test). With --quiet hardcoded, there is no feedback on success and no details on failure about what changed. We want uv's normal output (e.g. "Resolved 562 packages in 5.75s" on success, or the list of changed packages on failure).

Proposed solution

Add an optional quiet attribute to the lock() macro (defaulting to True to preserve existing behavior) that controls whether --quiet and --no-progress are passed to the .run script:

lock(
    name = "uv_lock",
    srcs = ["pyproject.toml", "uv.lock"],
    out = "uv.lock",
    quiet = False,  # show uv output when running bazel run //:uv_lock.run
)

Workaround

We currently work around this by adding a custom Starlark rule (uv_lock_check_run) that inherits the same runfiles as .run but finds the uv binary at runtime and calls it directly without --quiet. This wrapper exists solely because the attribute is not exposed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions