Skip to content

feat: add uv toolchain extension#943

Open
jbedard wants to merge 1 commit intomainfrom
uv-toolchain
Open

feat: add uv toolchain extension#943
jbedard wants to merge 1 commit intomainfrom
uv-toolchain

Conversation

@jbedard
Copy link
Copy Markdown
Member

@jbedard jbedard commented Apr 23, 2026

Add a UV module extension/toolchain for fetching UV via bazel.

Changes are visible to end-users: yes

  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config): no
  • Suggested release notes appear below: yes

The uv module extension's new toolchain() tag downloads a hermetic uv and publishes @uv (host alias) plus @uv//:all (per-platform toolchains).

Test plan

  • Covered by existing test cases
  • New test cases added
  • Manual testing; bazel run @uv -- --help

@aspect-workflows
Copy link
Copy Markdown

aspect-workflows Bot commented Apr 23, 2026

Bazel 8 (Test)

⚠️ Buildkite build #3248 failed.


Bazel 9 (Test)

⚠️ Buildkite build #3248 failed.


Bazel 8 (Test)

e2e

All tests were cache hits

55 tests (100.0%) were fully cached saving 48s.


Bazel 9 (Test)

e2e

All tests were cache hits

55 tests (100.0%) were fully cached saving 44s.


Bazel 8 (Test)

examples/uv_pip_compile

All tests were cache hits

1 test (100.0%) was fully cached saving 444ms.


Buildifier

@jbedard jbedard force-pushed the uv-toolchain branch 4 times, most recently from 5e766ba to 062037c Compare April 23, 2026 22:49
@jbedard jbedard requested a review from Copilot April 23, 2026 22:49
chatgpt-codex-connector[bot]

This comment was marked as outdated.

This comment was marked as outdated.

@jbedard jbedard force-pushed the uv-toolchain branch 2 times, most recently from 46a5543 to 3dd4923 Compare April 23, 2026 23:13
@jbedard jbedard requested a review from Copilot April 23, 2026 23:16

This comment was marked as outdated.

chatgpt-codex-connector[bot]

This comment was marked as outdated.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 17 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/BUILD.bazel
Comment on lines +33 to +38
os_name = rctx.os.name
if os_name == "mac os x":
os_suffix = "apple-darwin"
elif os_name == "linux":
os_suffix = "unknown-linux-gnu"
elif os_name.startswith("windows"):
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_detect_host_platform() always returns *-unknown-linux-gnu for Linux hosts. On musl-based distros (e.g. Alpine) this will point @uv//:uv at the gnu build, which may not run. The repo already has host libc detection logic in py/private/interpreter/resolve.bzl; consider using a similar approach here so the host alias chooses unknown-linux-musl when appropriate.

Copilot uses AI. Check for mistakes.
@jbedard jbedard force-pushed the uv-toolchain branch 3 times, most recently from 7e118d0 to dd5e7dc Compare April 23, 2026 23:58
@jbedard jbedard requested a review from Copilot April 23, 2026 23:59
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dd5e7dcec6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +36 to +37
elif os_name == "linux":
os_suffix = "unknown-linux-gnu"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Detect Linux libc before selecting uv binary

_detect_host_platform currently maps every Linux host to *-unknown-linux-gnu, so on musl-based systems (for example Alpine) the generated @uv//:uv alias points to a glibc build. uv’s Linux policy distinguishes glibc and musl artifacts, and the glibc binary can fail to execute on musl hosts even though musl archives are available in UV_VERSIONS; host platform detection needs to account for libc (or provide an explicit override) to avoid broken toolchain use on musl environments.

Useful? React with 👍 / 👎.

Comment thread docs/uv.md Outdated

This comment was marked as outdated.

@jbedard jbedard force-pushed the uv-toolchain branch 2 times, most recently from a890964 to 11aabbc Compare April 24, 2026 00:27

This comment was marked as outdated.

@jbedard jbedard force-pushed the uv-toolchain branch 3 times, most recently from a01ab18 to eab2c58 Compare April 24, 2026 00:46
@jbedard jbedard marked this pull request as ready for review April 24, 2026 00:53
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eab2c58c4e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +20 to +23
else:
os_constraint = "@platforms//os:linux"

return "[\"{}\", \"{}\"]".format(os_constraint, cpu)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add libc constraints to Linux UV toolchains

_platform_constraints maps every Linux triple to only @platforms//os:linux plus CPU, so x86_64-unknown-linux-gnu and x86_64-unknown-linux-musl (and the aarch64 pair) register with identical exec_compatible_with. With register_toolchains("@uv//:all"), Bazel cannot reliably distinguish libc variants and may resolve the glibc archive on musl exec platforms (e.g. Alpine), which can make tool invocations fail at runtime.

Useful? React with 👍 / 👎.

Comment on lines +533 to +537
uv_hub_repository(
name = hub_name,
version = cfg.version,
platforms = hashes.keys(),
repo_prefix = repo_prefix,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prevent toolchain repo name collisions with uv hubs

This creates a repository named after uv.toolchain(name = ...) in the same namespace used by uv.declare_hub(hub_name = ...), but there is no cross-check for collisions. If a module declares a dependency hub named "uv" (or any matching toolchain name) and also uses uv.toolchain() defaults, extension evaluation attempts to create two repos with the same name and fails with a duplicate-repository error.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants