Skip to content

refactor: refactoring venv assembly system#1298

Draft
xangcastle wants to merge 19 commits into
mainfrom
xangcastle/venv
Draft

refactor: refactoring venv assembly system#1298
xangcastle wants to merge 19 commits into
mainfrom
xangcastle/venv

Conversation

@xangcastle

Copy link
Copy Markdown
Member

Changes are visible to end-users: yes/no

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

Test plan

  • Covered by existing test cases
  • New test cases added
  • Manual testing; please provide instructions so we can reproduce:

@aspect-workflows

aspect-workflows Bot commented Jul 15, 2026

Copy link
Copy Markdown

✨ Aspect Workflows Tasks

📅 Thu Jul 16 17:29:15 UTC 2026

❌ 6 failed tasks

  • ❌ buildifier · ⏱ 23.1s · 🐙 GitHub Actions · ☑️ Check
    💬 failed in diff · Format failed (1 file needs format)
  • ❌ gazelle · ⏱ 22.8s · 🐙 GitHub Actions · ☑️ Check
    💬 failed in diff · Gazelle failed (1 out of date)
  • ❌ test-e2e-bazel-8 [test] · ⏱ 2m 32s · 🐙 GitHub Actions · ☑️ Check
    💬 failed in test · Bazel test failed (4 tests failed)
  • ❌ test-e2e-bazel-9 [test] · ⏱ 2m 37s · 🐙 GitHub Actions · ☑️ Check
    💬 failed in test · Bazel test failed (4 tests failed)
  • ❌ test-root-bazel-8 [test] · ⏱ 2m 58s · 🐙 GitHub Actions · ☑️ Check
    💬 failed in test · Bazel test failed (4 tests failed)
  • ❌ test-root-bazel-9 [test] · ⏱ 3m 22s · 🐙 GitHub Actions · ☑️ Check
    💬 failed in test · Bazel test failed (4 tests failed)

✅ 34 successful tasks

  • ✅ test-e2e-interpreter-build-config-bazel-8 [test] · ⏱ 19.4s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-interpreter-build-config-bazel-9 [test] · ⏱ 43.9s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-interpreter-input-validation-bazel-8 [test] · ⏱ 15.6s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-interpreter-input-validation-bazel-9 [test] · ⏱ 43s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-interpreter-runtime-metadata-bazel-8 [test] · ⏱ 27.7s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (2/2 passed · 2 cached)
  • ✅ test-e2e-interpreter-runtime-metadata-bazel-9 [test] · ⏱ 56.1s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (2/2 passed)
  • ✅ test-e2e-interpreter-toolchain-settings-bazel-8 [test] · ⏱ 14.5s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-interpreter-toolchain-settings-bazel-9 [test] · ⏱ 33s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-rules-proto-grpc-python-bazel-8 [test] · ⏱ 1m 51s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-rules-proto-grpc-python-bazel-9 [test] · ⏱ 54.8s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-rules-python-interop-bazel-8 [test] · ⏱ 26.1s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (6/6 passed)
  • ✅ test-e2e-rules-python-interop-bazel-9 [test] · ⏱ 1m 20s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (6/6 passed)
  • ✅ test-examples-debugger-bazel-8 [test] · ⏱ 30s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed · 1 cached)
  • ✅ test-examples-debugger-bazel-9 [test] · ⏱ 49s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-dev_deps-bazel-8 [test] · ⏱ 25.2s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed · 1 cached)
  • ✅ test-examples-dev_deps-bazel-9 [test] · ⏱ 45.6s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-django-bazel-8 [test] · ⏱ 23.6s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-django-bazel-9 [test] · ⏱ 1m 14s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-multi_version-bazel-8 [test] · ⏱ 31.5s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (2/2 passed)
  • ✅ test-examples-multi_version-bazel-9 [test] · ⏱ 52.2s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (2/2 passed)
  • ✅ test-examples-protobuf-bazel-8 [test] · ⏱ 1m 33s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-protobuf-bazel-9 [test] · ⏱ 2m 9s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-py_binary-bazel-8 [test] · ⏱ 26.4s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-py_binary-bazel-9 [test] · ⏱ 1m 2s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-py_pex_binary-bazel-8 [test] · ⏱ 22.3s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-py_pex_binary-bazel-9 [test] · ⏱ 48.9s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-py_venv-bazel-8 [test] · ⏱ 24.9s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (3/3 passed)
  • ✅ test-examples-py_venv-bazel-9 [test] · ⏱ 1m 31s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (3/3 passed)
  • ✅ test-examples-pytest-bazel-8 [test] · ⏱ 54.7s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (9/9 passed)
  • ✅ test-examples-pytest-bazel-9 [test] · ⏱ 1m 51s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (9/9 passed)
  • ✅ test-examples-uv_pip_compile-bazel-8 [test] · ⏱ 25.6s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-uv_pip_compile-bazel-9 [test] · ⏱ 39.3s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-virtual_deps-bazel-8 [test] · ⏱ 22.1s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-virtual_deps-bazel-9 [test] · ⏱ 51.6s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)

❌ Test Failures

❌ py_venv_exec_test //uv-sdist-fallback:test failed in 296ms:

exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //uv-sdist-fallback:test
-----------------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/.cache/bazel/_bazel_runner/bc392e71f7970e3c2154593992262559/sandbox/linux-sandbox/2554/execroot/_main/bazel-out/k8-fastbuild/bin/uv-sdist-fallback/test.runfiles/_main/uv-sdist-fallback/__test__.py", line 26, in <module>
    result = subprocess.run(
             ^^^^^^^^^^^^^^^
  File "/home/runner/.cache/bazel/_bazel_runner/bc392e71f7970e3c2154593992262559/external/aspect_rules_py++python_interpreters+python_3_11_x86_64_unknown_linux_gnu/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.cache/bazel/_bazel_runner/bc392e71f7970e3c2154593992262559/external/aspect_rules_py++python_interpreters+python_3_11_x86_64_unknown_linux_gnu/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/home/runner/.cache/bazel/_bazel_runner/bc392e71f7970e3c2154593992262559/external/aspect_rules_py++python_interpreters+python_3_11_x86_64_unknown_linux_gnu/lib/python3.11/subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/home/runner/.cache/bazel/_bazel_runner/bc392e71f7970e3c2154593992262559/sandbox/linux-sandbox/2554/execroot/_main/bazel-out/k8-fastbuild/bin/uv-sdist-fallback/test.runfiles/_main/uv-sdist-fallback/._test.venv/bin/cowsay'

in task test-e2e-bazel-8

Reproduce with:

cd e2e/cases
aspect test -- //uv-sdist-fallback:test
# vanilla bazel
cd e2e/cases
bazel test -- //uv-sdist-fallback:test

❌ py_venv_exec_test //uv-sdist-fallback:test failed in 216ms:

exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //uv-sdist-fallback:test
-----------------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/.cache/bazel/_bazel_runner/bc392e71f7970e3c2154593992262559/sandbox/linux-sandbox/3856/execroot/_main/bazel-out/k8-fastbuild/bin/uv-sdist-fallback/test.runfiles/_main/uv-sdist-fallback/__test__.py", line 26, in <module>
    result = subprocess.run(
             ^^^^^^^^^^^^^^^
  File "/home/runner/.cache/bazel-repo/contents/13cf291aaffbb42e2cdec5fd456f7cb620755fda40ef045962cd82f90e6087dc/efcff4db-6999-41dd-9230-ba189753c065/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.cache/bazel-repo/contents/13cf291aaffbb42e2cdec5fd456f7cb620755fda40ef045962cd82f90e6087dc/efcff4db-6999-41dd-9230-ba189753c065/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/home/runner/.cache/bazel-repo/contents/13cf291aaffbb42e2cdec5fd456f7cb620755fda40ef045962cd82f90e6087dc/efcff4db-6999-41dd-9230-ba189753c065/lib/python3.11/subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/home/runner/.cache/bazel/_bazel_runner/bc392e71f7970e3c2154593992262559/sandbox/linux-sandbox/3856/execroot/_main/bazel-out/k8-fastbuild/bin/uv-sdist-fallback/test.runfiles/_main/uv-sdist-fallback/._test.venv/bin/cowsay'

in task test-e2e-bazel-9

Reproduce with:

cd e2e/cases
aspect test -- //uv-sdist-fallback:test
# vanilla bazel
cd e2e/cases
bazel test -- //uv-sdist-fallback:test

❌ py_venv_exec_test //venv-bin-scripts-423:test failed in 152ms:

exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //venv-bin-scripts-423:test
-----------------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/.cache/bazel/_bazel_runner/bc392e71f7970e3c2154593992262559/sandbox/linux-sandbox/745/execroot/_main/bazel-out/k8-fastbuild/bin/venv-bin-scripts-423/test.runfiles/_main/venv-bin-scripts-423/__test__.py", line 27, in <module>
    result = subprocess.run(
             ^^^^^^^^^^^^^^^
  File "/home/runner/.cache/bazel/_bazel_runner/bc392e71f7970e3c2154593992262559/external/aspect_rules_py++python_interpreters+python_3_11_x86_64_unknown_linux_gnu/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.cache/bazel/_bazel_runner/bc392e71f7970e3c2154593992262559/external/aspect_rules_py++python_interpreters+python_3_11_x86_64_unknown_linux_gnu/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/home/runner/.cache/bazel/_bazel_runner/bc392e71f7970e3c2154593992262559/external/aspect_rules_py++python_interpreters+python_3_11_x86_64_unknown_linux_gnu/lib/python3.11/subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: 'venv-bin-scripts-423/._test.venv/bin/roll'

in task test-e2e-bazel-8

Reproduce with:

cd e2e/cases
aspect test -- //venv-bin-scripts-423:test
# vanilla bazel
cd e2e/cases
bazel test -- //venv-bin-scripts-423:test

❌ py_venv_exec_test //venv-bin-scripts-423:test failed in 197ms:

exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //venv-bin-scripts-423:test
-----------------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/.cache/bazel/_bazel_runner/bc392e71f7970e3c2154593992262559/sandbox/linux-sandbox/810/execroot/_main/bazel-out/k8-fastbuild/bin/venv-bin-scripts-423/test.runfiles/_main/venv-bin-scripts-423/__test__.py", line 27, in <module>
    result = subprocess.run(
             ^^^^^^^^^^^^^^^
  File "/home/runner/.cache/bazel-repo/contents/13cf291aaffbb42e2cdec5fd456f7cb620755fda40ef045962cd82f90e6087dc/efcff4db-6999-41dd-9230-ba189753c065/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.cache/bazel-repo/contents/13cf291aaffbb42e2cdec5fd456f7cb620755fda40ef045962cd82f90e6087dc/efcff4db-6999-41dd-9230-ba189753c065/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/home/runner/.cache/bazel-repo/contents/13cf291aaffbb42e2cdec5fd456f7cb620755fda40ef045962cd82f90e6087dc/efcff4db-6999-41dd-9230-ba189753c065/lib/python3.11/subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: 'venv-bin-scripts-423/._test.venv/bin/roll'

in task test-e2e-bazel-9

Reproduce with:

cd e2e/cases
aspect test -- //venv-bin-scripts-423:test
# vanilla bazel
cd e2e/cases
bazel test -- //venv-bin-scripts-423:test

❌ py_venv_exec_test //venv-bin-scripts-423:test_non_isolated failed in 169ms:

exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //venv-bin-scripts-423:test_non_isolated
-----------------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/.cache/bazel/_bazel_runner/bc392e71f7970e3c2154593992262559/sandbox/linux-sandbox/749/execroot/_main/bazel-out/k8-fastbuild/bin/venv-bin-scripts-423/test_non_isolated.runfiles/_main/venv-bin-scripts-423/__test__.py", line 27, in <module>
    result = subprocess.run(
             ^^^^^^^^^^^^^^^
  File "/home/runner/.cache/bazel/_bazel_runner/bc392e71f7970e3c2154593992262559/external/aspect_rules_py++python_interpreters+python_3_11_x86_64_unknown_linux_gnu/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.cache/bazel/_bazel_runner/bc392e71f7970e3c2154593992262559/external/aspect_rules_py++python_interpreters+python_3_11_x86_64_unknown_linux_gnu/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/home/runner/.cache/bazel/_bazel_runner/bc392e71f7970e3c2154593992262559/external/aspect_rules_py++python_interpreters+python_3_11_x86_64_unknown_linux_gnu/lib/python3.11/subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: 'venv-bin-scripts-423/._test_non_isolated.venv/bin/roll'

in task test-e2e-bazel-8

Reproduce with:

cd e2e/cases
aspect test -- //venv-bin-scripts-423:test_non_isolated
# vanilla bazel
cd e2e/cases
bazel test -- //venv-bin-scripts-423:test_non_isolated

+ 10 more failures — not shown (across test-e2e-bazel-8, test-e2e-bazel-9, test-root-bazel-8, test-root-bazel-9).

🛠️ Fix

❌ buildifier (buildifier)

aspect buildifier --severity=info -- py/private/py_venv/tests/BUILD.bazel
# vanilla bazel
bazel run --run_in_cwd @buildifier_prebuilt//buildifier -- py/private/py_venv/tests/BUILD.bazel

❌ gazelle (gazelle)

aspect gazelle --severity=info --check-only=false -- py/private/py_venv/tests
# vanilla bazel
bazel run //tools/gazelle:gazelle

Install aspect: aspect.build/docs/cli/install

🔁 Reproduce

❌ buildifier (buildifier)

aspect buildifier --severity=fail --base-ref=origin/main

❌ gazelle (gazelle)

aspect gazelle --severity=fail --check-only=true

❌ test (test-e2e-bazel-8)

cd e2e/cases
aspect test -- \
  //venv-bin-scripts-423:test_non_isolated \
  //venv-bin-scripts-423:test \
  //venv-bin-scripts-423:venv_test \
  //uv-sdist-fallback:test

❌ test (test-e2e-bazel-9)

cd e2e/cases
aspect test -- \
  //venv-bin-scripts-423:venv_test \
  //venv-bin-scripts-423:test \
  //venv-bin-scripts-423:test_non_isolated \
  //uv-sdist-fallback:test

❌ test (test-e2e-bazel-8)

# vanilla bazel
cd e2e/cases
bazel test -- \
  //venv-bin-scripts-423:test_non_isolated \
  //venv-bin-scripts-423:test \
  //venv-bin-scripts-423:venv_test \
  //uv-sdist-fallback:test

+ 5 more reproduce commands — not shown (across test-e2e-bazel-9, test-root-bazel-8, test-root-bazel-9).

Install aspect: aspect.build/docs/cli/install


⏱ Last updated Thu Jul 16 17:32:41 UTC 2026 · 📊 GitHub API quota 1,912/15,000 (13% used, resets in 1m)
🚀 Powered by Aspect CLI (v2026.28.2)  |  Aspect Build · X · LinkedIn · YouTube

@github-actions

github-actions Bot commented Jul 15, 2026

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) 179.581 176.265 ±14.774 65.03
HEAD main 56.479 56.078 ±1.111 -68.5% 10.26
This PR 56.370 56.327 ±0.485 -68.6% -0.2% 7.26

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.

Bazel analysis benchmark

Version Mean (ms) Median (ms) ± stddev vs BCR vs main Packages Targets
BCR 2.0.0-alpha.4 (baseline) 9849.110 9890.529 ±147.376 101 301
HEAD main 9176.323 9119.468 ±123.670 -6.8% 101 301
This PR 9210.261 9236.205 ±128.104 -6.5% +0.4% 101 301

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

Auxiliary metrics

Version Loaded packages Configured targets
BCR 2.0.0-alpha.4 (baseline) 101 301
HEAD main 101 301
This PR 101 301

@xangcastle xangcastle changed the title start refactoring venv assembly system refactor: refactoring venv assembly system Jul 15, 2026
@acozzette

Copy link
Copy Markdown
Collaborator

Code review findings

Ran a high-effort review (multi-angle finder pass + independent verification, including bazel build //... and the full test suite, which pass) over this refactor. 8 findings survived verification, ranked most severe first.

Correctness

  1. Collision-policy error message ordering changedvirtuals_resolvers.bzl:487
    _resolve_metadata_collisions's unconditional fail() now always runs to completion before the deferred enforce_collision_policy (assemble_venv.bzl:298) gets a chance to raise the recorded top-level/console-script collision message. A target with package_collisions = "error" that has both an ordinary top-level collision and an unrelated metadata-collision loser will always fail with the internal metadata-invariant message instead of the intended, actionable collision message. Build still fails either way, but the reported root cause is misleading. Pre-refactor pass ordering meant the top-level collision fired first.

  2. Snapshot tool silently drops absolute-target symlinkspy/private/py_venv/snapshots/venv_tree_snap.bzl:29
    The relative-target branch always emits a LINK line; the absolute-target branch only tries to inline the dereferenced file's contents (gated on -f + wc -c < 8192), with no unconditional LINK echo. For a non-hermetic/system Python toolchain, bin/python is an absolute-target symlink to a real interpreter binary (>8192 bytes) — the snapshot test silently omits it (no FILE, no LINK), so it wouldn't catch a regression in that symlink's target.

  3. pythonMAJOR.MINOR directory name duplicated 4x with no shared helpertoolchains_resolver.bzl:24
    The same "python{}.{}".format(major, minor) format string is independently written in toolchains_resolver.bzl, py_unpacked_wheel.bzl, and twice in unpack.py. These must stay byte-identical for wheel resolution to find the right site-packages dir; a future edit to one copy (padding, free-threaded suffix, etc.) without the others fails silently at runtime with no build-time signal.

Cleanup

  1. Redundant derivable parameter venv_nameassemble_venv.bzl:267
    Always constructed as ".{}".format(safe_name) at its one call site (py_venv.bzl:133) but threaded separately through ~6 helper functions instead of computed once internally.

  2. Dead parameter any_namespacevirtuals_resolvers.bzl:315
    _resolve_directory_collision never references it in its body; the caller computes it for nothing.

  3. Triplicated path-containment checkvirtuals_resolvers.bzl:15
    _is_within, _within_any, and _contains_any each inline the same path == root or path.startswith(root + "/") check instead of the latter two calling _is_within in a loop. _is_within itself is never called anywhere.

  4. _build_wheel_lookup_sets rebuilt 3-4x for the same claimant setvirtuals_resolvers.bzl:199
    Called independently in _scan_namespace_conflicts, _classify_conflicted_roots, and _resolve_native_span (plus an inline per-claimant rebuild), each discarding 2 of 3 returned dicts. Negligible perf impact at realistic wheel-collision counts, but pure waste.

  5. Stale docstring reference to a nonexistent providervirtuals_resolvers.bzl:569
    compute_wheel_plan's docstring says the struct has "all fields needed by PyWheelPlanInfo" — no such provider exists anywhere in the repo.

Two other candidates were investigated and refuted: an apparent -I interpreter-flag inconsistency between py_venv.bzl and py_venv_exec.bzl (intentional — only py_venv_exec has an isolated attribute), and an apparent duplicate toolchain-lookup pattern between assemble_venv.bzl and py_unpacked_wheel.bzl (correctly tracks each rule's different mandatory-vs-optional toolchain registration).

🤖 Generated with Claude Code

# Conflicts:
#	py/private/py_venv/BUILD.bazel
#	py/private/py_venv/py_venv.bzl
#	py/private/py_venv/tests/BUILD.bazel
# Conflicts:
#	py/private/py_venv/BUILD.bazel
#	py/private/py_venv/tests/BUILD.bazel
# Conflicts:
#	py/private/py_venv/py_venv.bzl
# Conflicts:
#	py/private/py_venv/BUILD.bazel
#	py/private/py_venv/py_venv.bzl
#	py/private/py_venv/tests/BUILD.bazel
# Conflicts:
#	py/private/py_venv/BUILD.bazel
#	py/private/py_venv/venv.bzl
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