Skip to content

refactor: split py_venv binary vs lib rules#980

Draft
jbedard wants to merge 2 commits into
mainfrom
py_venv-non-exec
Draft

refactor: split py_venv binary vs lib rules#980
jbedard wants to merge 2 commits into
mainfrom
py_venv-non-exec

Conversation

@jbedard
Copy link
Copy Markdown
Member

@jbedard jbedard commented May 7, 2026

This way if the py_venv is not being exposed via py_binary(expose_venv) it will be a simpler rule only exporting the VirtualenvInfo and runfiles, no RunEnvironmentInfo or DefaultInfo(files)

Changes are visible to end-users: no

Test plan

  • Covered by existing test cases

@jbedard jbedard force-pushed the py_venv-non-exec branch from 7bfe2db to 2e2bec7 Compare May 7, 2026 03:23
@aspect-workflows
Copy link
Copy Markdown

aspect-workflows Bot commented May 7, 2026

Bazel 8 (Test)

33 test targets passed

Targets
//examples/multi_version:py_version_default_test [k8-fastbuild]                               789ms
//examples/multi_version:py_version_test [k8-fastbuild]                                       841ms
//examples/py_venv:test_simple_binary [k8-fastbuild]                                          169ms
//examples/pytest/subdir:test_with_pytest_main [k8-fastbuild]                                 789ms
//examples/pytest/subdir:test_without_pytest_main [k8-fastbuild]                              229ms
//examples/pytest:absolute_main_test [k8-fastbuild]                                           267ms
//examples/pytest:chdir_test [k8-fastbuild]                                                   622ms
//examples/pytest:coverage_lcov_shape_test [k8-fastbuild]                                     1s
//examples/pytest:main_with_colon_test [k8-fastbuild]                                         442ms
//examples/pytest:pytest_test [k8-fastbuild]                                                  797ms
//examples/pytest:sharded/test [k8-fastbuild]                                                 2s
//examples/pytest:test_naming_723 [k8-fastbuild]                                              968ms
//examples/virtual_deps:pytest_test [k8-fastbuild]                                            1s
//py/private/py_venv:test_link [k8-fastbuild]                                                 492ms
//py/tests/console-scripts:test_console_scripts [k8-fastbuild]                                492ms
//py/tests/external-deps:test_can_import_runfiles_helper [k8-fastbuild]                       556ms
//py/tests/internal-deps:assert [k8-fastbuild]                                                348ms
//py/tests/interpreter-options:test_options_on_test [k8-fastbuild]                            362ms
//py/tests/main-from-genrule:main_from_genrule_test [k8-fastbuild]                            258ms
//py/tests/py-internal-venv:test [k8-fastbuild]                                               107ms
//py/tests/py-internal-venv:test_non_isolated [k8-fastbuild]                                  165ms
//py/tests/py-test:test_env_vars [k8-fastbuild]                                               331ms
//py/tests/py-venv-disable-systemsite:test [k8-fastbuild]                                     140ms
//py/tests/py-venv-disable-systemsite:test_non_isolated [k8-fastbuild]                        148ms
//py/tests/py-venv-disable-usersite:test [k8-fastbuild]                                       136ms
//py/tests/py-venv-disable-usersite:test_non_isolated [k8-fastbuild]                          130ms
//py/tests/py-venv-enable-site:test [k8-fastbuild]                                            130ms
//py/tests/py_venv_conflict:validate_import_roots [k8-fastbuild]                              658ms
//py/tests/py_venv_conflict:validate_import_roots_non_isolated [k8-fastbuild]                 474ms
//py/tests/repo_relative_imports/test:test [k8-fastbuild]                                     288ms
//uv/private/gazelle_manifest:test [k8-fastbuild]                                             800ms
//uv/private/markers:marker_arch_alias_test [k8-fastbuild]                                    374ms
//uv/private/sdist_configure:detect_native_test [k8-fastbuild]                                699ms

Total test execution time was 17s. 150 tests (82.0%) were fully cached saving 48s.


Bazel 9 (Test)

33 test targets passed

Targets
//examples/multi_version:py_version_default_test [k8-fastbuild]                               921ms
//examples/multi_version:py_version_test [k8-fastbuild]                                       905ms
//examples/py_venv:test_simple_binary [k8-fastbuild]                                          203ms
//examples/pytest/subdir:test_with_pytest_main [k8-fastbuild]                                 852ms
//examples/pytest/subdir:test_without_pytest_main [k8-fastbuild]                              367ms
//examples/pytest:absolute_main_test [k8-fastbuild]                                           313ms
//examples/pytest:chdir_test [k8-fastbuild]                                                   915ms
//examples/pytest:coverage_lcov_shape_test [k8-fastbuild]                                     621ms
//examples/pytest:main_with_colon_test [k8-fastbuild]                                         308ms
//examples/pytest:pytest_test [k8-fastbuild]                                                  444ms
//examples/pytest:sharded/test [k8-fastbuild]                                                 2s
//examples/pytest:test_naming_723 [k8-fastbuild]                                              576ms
//examples/virtual_deps:pytest_test [k8-fastbuild]                                            765ms
//py/private/py_venv:test_link [k8-fastbuild]                                                 524ms
//py/tests/console-scripts:test_console_scripts [k8-fastbuild]                                407ms
//py/tests/external-deps:test_can_import_runfiles_helper [k8-fastbuild]                       587ms
//py/tests/internal-deps:assert [k8-fastbuild]                                                496ms
//py/tests/interpreter-options:test_options_on_test [k8-fastbuild]                            399ms
//py/tests/main-from-genrule:main_from_genrule_test [k8-fastbuild]                            384ms
//py/tests/py-internal-venv:test [k8-fastbuild]                                               139ms
//py/tests/py-internal-venv:test_non_isolated [k8-fastbuild]                                  172ms
//py/tests/py-test:test_env_vars [k8-fastbuild]                                               330ms
//py/tests/py-venv-disable-systemsite:test [k8-fastbuild]                                     164ms
//py/tests/py-venv-disable-systemsite:test_non_isolated [k8-fastbuild]                        152ms
//py/tests/py-venv-disable-usersite:test [k8-fastbuild]                                       194ms
//py/tests/py-venv-disable-usersite:test_non_isolated [k8-fastbuild]                          129ms
//py/tests/py-venv-enable-site:test [k8-fastbuild]                                            137ms
//py/tests/py_venv_conflict:validate_import_roots [k8-fastbuild]                              604ms
//py/tests/py_venv_conflict:validate_import_roots_non_isolated [k8-fastbuild]                 637ms
//py/tests/repo_relative_imports/test:test [k8-fastbuild]                                     296ms
//uv/private/gazelle_manifest:test [k8-fastbuild]                                             661ms
//uv/private/markers:marker_arch_alias_test [k8-fastbuild]                                    294ms
//uv/private/sdist_configure:detect_native_test [k8-fastbuild]                                887ms

Total test execution time was 17s. 149 tests (81.9%) were fully cached saving 52s.


Bazel 8 (Test)

e2e

⚠️ Buildkite build #3912 failed.

Failed tests (5)
//cases/oci/py_image_layer:my_app_layers_test_test [k8-fastbuild]🔗
//cases/uv-deps-650/crossbuild:app_amd64_layers_test [k8-fastbuild]🔗
//cases/uv-deps-650/crossbuild:app_arm64_layers_test [k8-fastbuild]🔗
//cases/venv-bin-scripts-423:test [k8-fastbuild]🔗
//cases/venv-bin-scripts-423:test_non_isolated [k8-fastbuild]🔗

💡 To reproduce the test failures, run

bazel test //cases/venv-bin-scripts-423:test //cases/uv-deps-650/crossbuild:app_arm64_layers_test //cases/uv-deps-650/crossbuild:app_amd64_layers_test //cases/venv-bin-scripts-423:test_non_isolated //cases/oci/py_image_layer:my_app_layers_test_test

Bazel 9 (Test)

e2e

⚠️ Buildkite build #3912 failed.

Failed tests (3)
//cases/oci/py_image_layer:my_app_layers_test_test [k8-fastbuild]🔗
//cases/venv-bin-scripts-423:test [k8-fastbuild]🔗
//cases/venv-bin-scripts-423:test_non_isolated [k8-fastbuild]🔗

💡 To reproduce the test failures, run

bazel test //cases/venv-bin-scripts-423:test_non_isolated //cases/venv-bin-scripts-423:test //cases/oci/py_image_layer:my_app_layers_test_test

Bazel 8 (Test)

examples/uv_pip_compile

All tests were cache hits

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


Buildifier      Gazelle

@jbedard jbedard force-pushed the py_venv-non-exec branch 6 times, most recently from 9c55626 to 1b0356f Compare May 13, 2026 20:52
@jbedard jbedard force-pushed the py_venv-non-exec branch from 1b0356f to 7e9c886 Compare May 21, 2026 16:53
@jbedard jbedard force-pushed the py_venv-non-exec branch from 7e9c886 to b6b60c4 Compare June 5, 2026 23:08
@aspect-workflows
Copy link
Copy Markdown

aspect-workflows Bot commented Jun 5, 2026

✨ Aspect Workflows Tasks

📅 Fri Jun 5 23:09:07 UTC 2026

❌ 2 failed tasks

  • ❌ test (test-e2e-bazel-8) · ⏱ 2m 25s · 🐙 GitHub Actions · ☑️ Check
    💬 failed in test · Bazel test failed (5 tests failed)
  • ❌ test (test-e2e-bazel-9) · ⏱ 3m 21s · 🐙 GitHub Actions · ☑️ Check
    💬 failed in test · Bazel test failed (3 tests failed)

✅ 5 successful tasks

  • ✅ buildifier · ⏱ 19.1s · 🐙 GitHub Actions · ☑️ Check
    💬 Format complete (clean)
  • ✅ gazelle · ⏱ 19.1s · 🐙 GitHub Actions · ☑️ Check
    💬 Gazelle complete (clean)
  • ✅ test (test-examples-uv_pip_compile-bazel-8) · ⏱ 31.7s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed · 1 cached)
  • ✅ test (test-root-bazel-8) · ⏱ 1m 54s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (185/185 passed)
  • ✅ test (test-root-bazel-9) · ⏱ 2m 8s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (184/184 passed)

🔁 Reproduce

❌ test (test-e2e-bazel-8)

aspect test -- \
  //cases/oci/py_image_layer:my_app_layers_multi_test_test \
  //cases/oci/py_image_layer:my_app_layers_fp_test_test \
  //cases/oci/py_image_layer:my_app_layers_test_test \
  //cases/uv-deps-650/crossbuild:app_arm64_layers_test \
  //cases/uv-deps-650/crossbuild:app_amd64_layers_test
# without Aspect CLI
bazel test -- \
  //cases/oci/py_image_layer:my_app_layers_multi_test_test \
  //cases/oci/py_image_layer:my_app_layers_fp_test_test \
  //cases/oci/py_image_layer:my_app_layers_test_test \
  //cases/uv-deps-650/crossbuild:app_arm64_layers_test \
  //cases/uv-deps-650/crossbuild:app_amd64_layers_test

❌ test (test-e2e-bazel-9)

aspect test -- \
  //cases/oci/py_image_layer:my_app_layers_multi_test_test \
  //cases/oci/py_image_layer:my_app_layers_test_test \
  //cases/oci/py_image_layer:my_app_layers_fp_test_test
# without Aspect CLI
bazel test -- \
  //cases/oci/py_image_layer:my_app_layers_multi_test_test \
  //cases/oci/py_image_layer:my_app_layers_test_test \
  //cases/oci/py_image_layer:my_app_layers_fp_test_test

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


⏱ Last updated Fri Jun 5 23:12:59 UTC 2026 · 📊 GitHub API quota 20/15,000 (0% used, resets in 58m)
🚀 Powered by Aspect CLI (v2026.22.44)  |  Aspect Build · X · LinkedIn · YouTube

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

py_binary startup benchmark

Version Mean (ms) Median (ms) ± stddev vs BCR vs main Build (s)
BCR 1.11.5 (baseline) 311.711 310.482 ±7.755 27.22
HEAD main 59.018 58.979 ±0.438 -81.1% 11.71
This PR 58.904 58.864 ±0.359 -81.1% -0.2% 10.04

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.5 (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.

jbedard added a commit that referenced this pull request Jun 8, 2026
Some tests that would have caught a regression in
#980 🤷

### Changes are visible to end-users: no

### Test plan

- New test cases added
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