Skip to content

fix(uv): deduplicate whl_install wheel file labels#1208

Open
jimmyt857 wants to merge 1 commit into
aspect-build:mainfrom
jimmyt857:jimmy/fix-uv-duplicate-whl-labels
Open

fix(uv): deduplicate whl_install wheel file labels#1208
jimmyt857 wants to merge 1 commit into
aspect-build:mainfrom
jimmyt857:jimmy/fix-uv-duplicate-whl-labels

Conversation

@jimmyt857

Copy link
Copy Markdown
Contributor

Summary

uv.lock can contain multiple wheel entries that resolve to the same fetched wheel repository label. One way this happens is when duplicate package records have wheel URLs with different basenames but the same hash, so rules_py fetches them through the same http_file repository.

Before this change, the uv extension forwarded those duplicate labels directly to the whl_install.whl_files label_list attr. Bazel rejects duplicate labels during repository rule instantiation, so the install fails before wheel metadata can be extracted.

This change deduplicates the non-empty wheel file labels while preserving order, then changes whl_install metadata extraction to map the deduplicated labels back to the serialized prebuild targets by label string instead of relying on positional pairing. That keeps the label_list valid without losing top-level metadata for selectable wheels.

Regression Test

Adds e2e/cases/uv-duplicate-whl-labels, whose lockfile contains two six==1.16.0 wheel entries with the same hash and different wheel basenames. Without the fix, the test fails during repository rule setup with a duplicate whl_files label error.

Testing

  • bazel run //:gazelle
  • bazel test //uv/private/extension:all //uv/private/whl_install:all
  • (cd e2e && bazel test //cases/uv-duplicate-whl-labels:test_import //cases/uv-dup-lock-records:all)
  • pre-commit run buildifier --files e2e/MODULE.bazel e2e/cases/uv-duplicate-whl-labels/BUILD.bazel e2e/cases/uv-duplicate-whl-labels/setup.MODULE.bazel uv/private/extension/defs.bzl uv/private/whl_install/repository.bzl

Note: pre-commit run buildifier-lint --files ... still reports existing warnings in touched upstream files, so I kept this patch focused on the regression rather than sweeping unrelated lint cleanup.

@xangcastle xangcastle self-requested a review June 27, 2026 03:57
@github-actions

Copy link
Copy Markdown

py_binary startup benchmark

Version Mean (ms) Median (ms) ± stddev vs BCR vs main Build (s)
BCR 1.11.7 (baseline) 193.037 190.524 ±9.350 40.85
HEAD main 60.817 60.708 ±0.591 -68.5% 9.59
This PR 61.749 60.649 ±4.701 -68.0% +1.5% 6.93

Measured with hyperfine --warmup 5 --runs 50 on Linux
Gate: PR vs HEAD main (threshold: 10%). BCR is shown only as a historical baseline.
Build time: cold bazel build //:bench with isolated output base, no disk cache.

sys.path quality

Version sys.path entries distinct site-packages roots duplicate realpaths
BCR 1.11.7 (baseline) 6 1 0
HEAD main 7 2 0
This PR 7 2 0

sys.path quality measured by bench_syspath inside the assembled venv. Duplicate realpaths indicate symlink redundancy; many distinct site-packages roots suggest an inefficient venv layout.

✅ No regression detected (PR is +1.5% vs HEAD main)

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