Skip to content

Conversation

@arrdem
Copy link
Collaborator

@arrdem arrdem commented Nov 4, 2025

Paired with @alexeagle. It used to be before recent improvements to runfiles tree identification and the venv shim that we relied on the activate script to set PYTHONEXECUTABLE. This proved to be unreliable, in part because many tools just don't evaluate the activate script.

Setting the PYTHONEXECUTABLE without also setting PYTHONHOME breaks non-Bazel Python invocations and so is a bug. Furthermore we didn't save/restore or more importantly unset PYTHONEXECUTABLE during deactivate, which broke shell environments.

Just don't set this.

Fixes #671.

Changes are visible to end-users: yes

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

Fixed #671, activate scripts no longer poison the shell env.

Test plan

  • Manual testing

Paired with @alexeagle. It used to be before recent improvements to
runfiles tree identification and the venv shim that we relied on the
activate script to set PYTHONEXECUTABLE. This proved to be unreliable,
in part because many tools just don't evaluate the activate script.

Setting the PYTHONEXECUTABLE without also setting PYTHONHOME breaks
non-Bazel Python invocations and so is a bug. Furthermore we didn't
save/restore or more importantly unset PYTHONEXECUTABLE during
deactivate, which broke shell environments.

Just don't set this.

Fixes #671.
@arrdem arrdem requested a review from alexeagle November 4, 2025 07:36
@arrdem arrdem self-assigned this Nov 4, 2025
@aspect-workflows
Copy link

aspect-workflows bot commented Nov 4, 2025

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

2 test targets passed

Targets
//py/tests/py_venv_image_layer:my_app_amd64_layers_test [k8-fastbuild]           61ms
//py/tests/py_venv_image_layer:my_app_arm64_layers_test [k8-fastbuild]           68ms

Total test execution time was 129ms. 36 tests (94.7%) were fully cached saving 59s.


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

All tests were cache hits

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


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

e2e

All tests were cache hits

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


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

e2e

All tests were cache hits

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


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.

@arrdem arrdem merged commit 9661dd7 into main Nov 4, 2025
2 checks passed
@arrdem arrdem deleted the arrdem/fix-671 branch November 4, 2025 17:32
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.

activating venv prevents running py_binary targets

3 participants