diff --git a/docs/concepts/authentication/cli.md b/docs/concepts/authentication/cli.md index 2a8d85661d..e9d94dcd73 100644 --- a/docs/concepts/authentication/cli.md +++ b/docs/concepts/authentication/cli.md @@ -87,36 +87,8 @@ If no credentials are found, uv will return an empty set of headers: `uv auth helper` is experimental. Use `--preview-features auth-helper` or `UV_PREVIEW_FEATURES=auth-helper` to disable the warning. -### Bazel - -Bazel 7 and newer supports credential helpers via the `--credential_helper` option. First, -authenticate uv with the service that hosts the files Bazel needs to fetch: - -```console -$ uv auth login https://packages.example.com -``` - -Then, configure Bazel to invoke uv for matching hosts: - -```text title=".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`: - -```bash title="bazel/uv-auth-helper" -#!/usr/bin/env bash -exec uv --preview-features auth-helper auth helper --protocol=bazel "$@" -``` - -The script must be executable: - -```console -$ chmod +x bazel/uv-auth-helper -``` +The [Bazel integration guide](../../guides/integration/bazel.md) explains how to use this command +with Bazel. ## Configuring the storage backend diff --git a/docs/guides/integration/bazel.md b/docs/guides/integration/bazel.md new file mode 100644 index 0000000000..471740eda6 --- /dev/null +++ b/docs/guides/integration/bazel.md @@ -0,0 +1,44 @@ +--- +title: Using uv with Bazel +description: Using uv to power package resolution with Bazel +--- + +# Using uv with Bazel + +For broader Bazel workflows with uv, see the +[`rules_py` uv guide](https://github.com/aspect-build/rules_py#dependency-resolution-with-uv) or the +[`rules_python` uv guide](https://rules-python.readthedocs.io/en/latest/pypi/lock.html#uv-pip-compile-bzlmod-only). + +## 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: + +```console +$ uv auth login https://packages.example.com +``` + +Then, configure Bazel to invoke +[`uv auth helper`](../../concepts/authentication/cli.md#using-credentials-with-external-tools) for +matching hosts: + +```text title=".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`: + +```bash title="bazel/uv-auth-helper" +#!/usr/bin/env bash +exec uv --preview-features auth-helper auth helper --protocol=bazel "$@" +``` + +The script must be executable: + +```console +$ chmod +x bazel/uv-auth-helper +``` diff --git a/docs/guides/integration/index.md b/docs/guides/integration/index.md index d7b7c70a96..dc15a32654 100644 --- a/docs/guides/integration/index.md +++ b/docs/guides/integration/index.md @@ -10,6 +10,7 @@ Learn how to integrate uv with other software: - [Using in GitLab CI/CD](./gitlab.md) - [Installing PyTorch](./pytorch.md) - [Building a FastAPI application](./fastapi.md) +- [Using with Bazel](./bazel.md) - [Using with Azure Artifacts](./azure.md) - [Using with Google Artifact Registry](./google.md) - [Using with AWS CodeArtifact](./aws.md) diff --git a/mkdocs.yml b/mkdocs.yml index 56dcd53991..fea141974a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -118,6 +118,7 @@ plugins: - guides/integration/pre-commit.md - guides/integration/pytorch.md - guides/integration/fastapi.md + - guides/integration/bazel.md - guides/integration/azure.md - guides/integration/google.md - guides/integration/aws.md @@ -203,6 +204,7 @@ nav: - Pre-commit: guides/integration/pre-commit.md - PyTorch: guides/integration/pytorch.md - FastAPI: guides/integration/fastapi.md + - Bazel: guides/integration/bazel.md - Azure Artifacts: guides/integration/azure.md - Google Artifact Registry: guides/integration/google.md - AWS CodeArtifact: guides/integration/aws.md