Skip to content

refactor: split py_venv binary vs lib rules#980

Merged
xangcastle merged 1 commit into
mainfrom
py_venv-non-exec
Jun 26, 2026
Merged

refactor: split py_venv binary vs lib rules#980
xangcastle merged 1 commit into
mainfrom
py_venv-non-exec

Conversation

@jbedard

@jbedard jbedard commented May 7, 2026

Copy link
Copy Markdown
Member

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

aspect-workflows Bot commented May 7, 2026

Copy link
Copy Markdown

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

aspect-workflows Bot commented Jun 5, 2026

Copy link
Copy Markdown

✨ Aspect Workflows Tasks

📅 Fri Jun 26 19:55:08 UTC 2026

✅ 14 successful tasks

  • ✅ buildifier · ⏱ 23.6s · 🐙 GitHub Actions · ☑️ Check
    💬 Format complete (clean)
  • ✅ gazelle · ⏱ 30.1s · 🐙 GitHub Actions · ☑️ Check
    💬 Gazelle complete (clean)
  • ✅ test-e2e-bazel-8 [test] · ⏱ 3m 5s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (182/182 passed)
  • ✅ test-e2e-bazel-9 [test] · ⏱ 4m 30s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (177/177 passed)
  • ✅ test-examples-debugger-bazel-8 [test] · ⏱ 29.3s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed · 1 cached)
  • ✅ test-examples-debugger-bazel-9 [test] · ⏱ 51.4s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-dev_deps-bazel-8 [test] · ⏱ 33.3s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed · 1 cached)
  • ✅ test-examples-dev_deps-bazel-9 [test] · ⏱ 41.5s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-protobuf-bazel-8 [test] · ⏱ 1m 46s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-protobuf-bazel-9 [test] · ⏱ 3m 22s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-uv_pip_compile-bazel-8 [test] · ⏱ 30.4s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed · 1 cached)
  • ✅ test-examples-uv_pip_compile-bazel-9 [test] · ⏱ 35s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-root-bazel-8 [test] · ⏱ 3m 25s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (217/217 passed)
  • ✅ test-root-bazel-9 [test] · ⏱ 3m 33s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (216/216 passed)

⏱ Last updated Fri Jun 26 19:59:43 UTC 2026 · 📊 GitHub API quota 58/15,000 (0% used, resets in 42m)
🚀 Powered by Aspect CLI (v2026.26.18)  |  Aspect Build · X · LinkedIn · YouTube

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

py_binary startup benchmark

Version Mean (ms) Median (ms) ± stddev vs BCR vs main Build (s)
BCR 1.11.5 (baseline) 174.472 174.122 ±1.490 77.04
HEAD main 57.054 56.896 ±0.855 -67.3% 10.12
This PR 56.953 56.749 ±0.873 -67.4% -0.2% 7.40

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.

✅ No regression detected (PR is -0.2% vs HEAD main)

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
@jbedard jbedard force-pushed the py_venv-non-exec branch from b6b60c4 to d800794 Compare June 16, 2026 07:44
jbedard referenced this pull request Jun 22, 2026
Assemble each executable's private runtime venv in its owning rule
rather than creating a configured sibling target. The sibling transition
forced main-file resolution before configurable srcs were available and
added a target for every py_binary and py_test.

Keep physical sibling venv targets only for explicitly exposed layouts.
@jbedard jbedard force-pushed the py_venv-non-exec branch 3 times, most recently from eab1f49 to 9ece534 Compare June 26, 2026 03:15
@jbedard jbedard marked this pull request as ready for review June 26, 2026 03:24
@jbedard jbedard requested a review from xangcastle June 26, 2026 03:24
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@jbedard jbedard force-pushed the py_venv-non-exec branch from 9ece534 to dea7beb Compare June 26, 2026 19:41
@jbedard jbedard force-pushed the py_venv-non-exec branch from dea7beb to 9872c8e Compare June 26, 2026 19:54
@xangcastle xangcastle merged commit 8fa507f into main Jun 26, 2026
31 checks passed
@xangcastle xangcastle deleted the py_venv-non-exec branch June 26, 2026 21:48
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