Skip to content

Conversation

@arrdem
Copy link
Collaborator

@arrdem arrdem commented Jan 9, 2026

Fix a bug when a requirement with no bdists is depended on as a whl rather than as a py_library which manifests as build not found errors which are confusing because in lib mode, the requirement will build just fine.

In order to facilitate future pex/sci-e/zipapp support, one of the features of the uv machinery is that the requirements graph can be configured so that dependencies occur either as installed library trees OR as pre-install wheel files. This solves a persistent issue with zipapp-like things of needing to re-zip/re-whl files which have already been installed, leading to among other things useless I/O and whls inside zipapps which may differ from the distribution whls.

This bug arises because once the transition flag is set from lib (the default) to whl by a py_whl_library as part of a venv's hub, that flag is never reset back to lib which needs to happen in order for sdist builds with dependencies to succeed. Sdist builds require that dependencies be installed, whl files do not suffice.

Ideally we'd use Fabian's resettable targets from with_cfg.bzl, however using his resetters creates problems. So do the lame but obviously correct thing of handwriting equivalent transitions.

Changes are visible to end-users: no

Test plan

Repairs building all targets under a uv-defined hub, which was previously broken.

❯ bazel build @pypi//... 
INFO: Analyzed 218 targets (71 packages loaded, 1481 targets configured).
INFO: Found 218 targets...
Target @@+uv+venv__pypi__default//pytest/entrypoints:py.test up-to-date:
  bazel-bin/external/+uv+venv__pypi__default/pytest/entrypoints/py.test
Target @@+uv+venv__pypi__default//pytest/entrypoints:pytest up-to-date:
  bazel-bin/external/+uv+venv__pypi__default/pytest/entrypoints/pytest
INFO: Elapsed time: 0.824s, Critical Path: 0.11s
INFO: 15 processes: 13 internal, 2 linux-sandbox.
INFO: Build completed successfully, 15 total actions

@aspect-workflows
Copy link

aspect-workflows bot commented Jan 9, 2026

test-os:linux-bzl:8 (Test)

All tests were cache hits

38 tests (100.0%) were fully cached saving 60s.


test-os:linux-bzl:latest (Test)

All tests were cache hits

38 tests (100.0%) were fully cached saving 41s.


test-os:linux-bzl:8 (Test)

e2e

All tests were cache hits

14 tests (100.0%) were fully cached saving 10s.


test-os:linux-bzl:latest (Test)

e2e

All tests were cache hits

14 tests (100.0%) were fully cached saving 11s.


test-os:linux-bzl:8 (Test)

examples/uv_pip_compile

All tests were cache hits

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


test-os:linux-bzl:latest (Test)

examples/uv_pip_compile

All tests were cache hits

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

])

original_settings(
name = "py_library_original_settings",
Copy link
Collaborator

Choose a reason for hiding this comment

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

i don't see this string used anywhere, is this doing something very magical? mind leaving a comment explaining?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is #deadwood, will remove.

@arrdem arrdem enabled auto-merge (squash) January 15, 2026 18:19
@arrdem arrdem disabled auto-merge January 15, 2026 19:03
@arrdem arrdem merged commit 76548d2 into main Jan 15, 2026
4 checks passed
@arrdem arrdem deleted the arrdem/fix-whl-buildgraph branch January 15, 2026 19:03
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.

4 participants