tree: 9d2fef06290552568179ecceae1b93c89f5e8cbe
  1. .bazelrc
  2. .bazelversion
  3. BUILD.bazel
  4. MODULE.bazel
  5. README.md
  6. requirements.in
  7. requirements.txt
  8. uv_runner.bzl
  9. WORKSPACE
tests/integration/uv_lock/README.md

uv_lock integration test workspace

This directory is a self-contained Bazel workspace used by the //tests/integration:uv_lock_test integration test.

It demonstrates how to use the lock() macro from @rules_python//python/uv to pin requirements with uv pip compile.

Targets

TargetDescription
//:requirementsBuild action that produces the locked requirements file
//:requirements.updateUpdate the in-source requirements.txt via bazel run
//:requirements.runRun uv pip compile with extra command-line args
//:requirements_diff_testDiff test comparing the lock output to the in-source file
//:uvThe uv binary from the registered toolchain

Workflow for debugging

If you want to debug and play around, you can start the server and then run the uv lock command manually.

Start the local PyPI server

In a separate terminal, start the pypiserver that serves the my-local-pkg test wheel:

bazel run //tests/integration:uv_lock_pypi_server [-- --no-auth]

The server prints the URL to use (with and without authentication) and the SHA256 of the wheel. Pass --no-auth to allow anonymous access.

Lock the requirements

With the server running, lock the requirements from this directory:

cd tests/integration/uv_lock
bazel run //:requirements.update               \
    --action_env=UV_EXTRA_INDEX_URL="<auth-url>" \
    --action_env=UV_CREDENTIALS_DIR=<creds-dir>

The <auth-url> and <creds-dir> values are printed by the pypi-server.

Verify the lock output matches the in-source file

bazel test //:requirements_diff_test

bazel-in-bazel Testing

When iterating on changes to lock.bzl, the integration test can be run directly from rules_python:

bazel test //tests/integration:uv_lock_test_bazel_self \
    --config=fast-tests \
    --test_output=streamed \
    --test_filter=<test_name>