Skip to content

Using uv with Bazel

For broader Bazel workflows with uv, see the rules_py uv guide or the rules_python uv guide.

Authentication

Bazel 7 and newer supports credential helpers via the --credential_helper option. To use credentials stored by uv for Bazel fetches, first authenticate uv with the service that hosts the files Bazel needs to fetch:

$ uv auth login https://packages.example.com

Then, configure Bazel to invoke uv auth helper for matching hosts:

.bazelrc
common --credential_helper=packages.example.com=%workspace%/bazel/uv-auth-helper
common --credential_helper=files.example.com=%workspace%/bazel/uv-auth-helper

Replace the host patterns with the hosts that serve the index and files Bazel will fetch.

Finally, add the wrapper script referenced by .bazelrc:

bazel/uv-auth-helper
#!/usr/bin/env bash
exec uv --preview-features auth-helper auth helper --protocol=bazel "$@"

The script must be executable:

$ chmod +x bazel/uv-auth-helper