Skip to content

Implement full module extension with toolchain, libc detection, and Gazelle manifest#947

Open
xangcastle wants to merge 4 commits intomainfrom
xangcastle/uv-unstable-extension
Open

Implement full module extension with toolchain, libc detection, and Gazelle manifest#947
xangcastle wants to merge 4 commits intomainfrom
xangcastle/uv-unstable-extension

Conversation

@xangcastle
Copy link
Copy Markdown
Member

@xangcastle xangcastle commented Apr 24, 2026

Replaces the stub uv/unstable/extension.bzl (previously a one-liner alias to the
stable extension) with a complete, self-contained module extension that owns its own
toolchain download, platform detection, and Gazelle integration.

New features

Hermetic UV toolchain provisioning (uv/private/toolchain/)

  • uv_repository: downloads a UV binary for a specific platform from GitHub releases
    with optional SHA256 verification
  • uv_host_repository: auto-detects the host platform and provisions the correct
    binary
  • uv_platform_repository: selects the right binary for the current Bazel execution
    environment
  • uv_toolchains_hub: wires all per-platform repos into a single toolchain_type hub
    across 7 supported platforms (macOS arm/x86, Linux glibc/musl arm/x86, Windows x86)
  • New uv_tool_toolchain rule and UvToolInfo provider in
    uv/private/toolchain/types.bzl

Host libc detection (uv/private/constraints/libc/)

  • detect_libc() function that inspects ldd --version, musl dynamic linker presence,
    and /etc/os-release to distinguish glibc from musl at repository-fetch time
  • libc_detector repository rule that writes the detected variant into a generated
    defs.bzl (LIBC_VARIANT) and config_setting targets

Gazelle manifest generation from uv.lock (uv/unstable/gazelle.bzl,
uv/unstable/lock_parser.bzl)

  • gazelle_python_yaml_repository: repository rule that downloads wheels listed in
    uv.lock, inspects each wheel's top_level.txt (with directory-scan fallback) to map
    import names → package names, and emits a gazelle_python.yaml
  • lock_parser.bzl: minimal uv.lock parser that extracts per-platform wheel URLs and
    SHA256 hashes without requiring a full TOML library
  • Exposed as the new gazelle_manifest tag class on the unstable extension

Full uv module extension (uv/unstable/extension.bzl)

  • Upgraded from uv = _uv alias to a complete module_extension with six tag classes:
    toolchain, declare_hub, project, unstable_annotate_packages, override_package,
    gazelle_manifest
  • Delegates dependency resolution to the stable uv_impl while adding toolchain
    setup, libc detection, and Gazelle manifest generation on top

Tests

  • //uv/unstable:inspect_wheel_test — 10 unit tests for the wheel inspection logic
    (top_level.txt, directory scan fallback, metadata exclusion, name normalisation)
  • //uv/private/constraints/libc:detect_libc_test — 8 unit tests for the libc
    detection heuristics via a Python mirror of the Starlark logic
  • //e2e/cases/uv-gazelle-unstable:test_gazelle_manifest — e2e test that exercises
    the new uv.gazelle_manifest() tag end-to-end and asserts the generated YAML contains
    the expected cowsay: cowsay mapping

Test plan

  • bazel test //uv/unstable:inspect_wheel_test
  • bazel test //uv/private/constraints/libc:detect_libc_test
  • bazel test //... in the root workspace (all existing tests continue to pass)
  • cd e2e && bazel test //cases/uv-gazelle-unstable:test_gazelle_manifest
  • cd e2e && bazel test //... (full e2e suite)

@aspect-workflows
Copy link
Copy Markdown

aspect-workflows Bot commented Apr 28, 2026

Bazel 8 (Test)

2 test targets passed

Targets
//uv/private/constraints/libc:detect_libc_test [k8-fastbuild-ST-32abbbcff250] 200ms
//uv/unstable:inspect_wheel_test [k8-fastbuild-ST-32abbbcff250]               351ms

Total test execution time was 551ms. 120 tests (98.4%) were fully cached saving 57s.


Bazel 9 (Test)

2 test targets passed

Targets
//uv/private/constraints/libc:detect_libc_test [k8-fastbuild-ST-32abbbcff250] 169ms
//uv/unstable:inspect_wheel_test [k8-fastbuild-ST-32abbbcff250]               387ms

Total test execution time was 556ms. 119 tests (98.3%) were fully cached saving 1m 4s.


Bazel 8 (Test)

e2e

1 test target passed

Targets
//cases/uv-gazelle-unstable:test_gazelle_manifest [k8-fastbuild-ST-1a8602e72ef0]429ms

Total test execution time was 429ms. 54 tests (98.2%) were fully cached saving 60s.


Bazel 9 (Test)

e2e

1 test target passed

Targets
//cases/uv-gazelle-unstable:test_gazelle_manifest [k8-fastbuild-ST-1a8602e72ef0]568ms

Total test execution time was 568ms. 54 tests (98.2%) were fully cached saving 55s.


Bazel 8 (Test)

examples/uv_pip_compile

All tests were cache hits

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


Buildifier

@xangcastle xangcastle marked this pull request as ready for review April 28, 2026 21:00
@xangcastle xangcastle changed the title uv unstable extension New UV extension Apr 28, 2026
@xangcastle xangcastle changed the title New UV extension Implement full module extension with toolchain, libc detection, and Gazelle manifest Apr 28, 2026
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.

1 participant