Skip to content

Commit 84f5644

Browse files
authored
tweak(py_venv): Don't modifying shell flags in activate (#669)
### Changes are visible to end-users: yes When creating a virtual environment, the `activate` script no longer modifies bash flags. These flags were added in #576 (v1.6.0) (note, they don't appear in the scripts that Python's `venv` module generates). <!-- If no, please delete this section. --> - Searched for relevant documentation and updated as needed: yes (behaviour is not documented) - Breaking change (forces users to change their own code or config):no - Suggested release notes appear below: yes/no ### Test plan - Manual testing; please provide instructions so we can reproduce: Potentially, users could have some tests running the following commands. The new flags introduced in #576 broke this kind of tests: ```sh #!/usr/bin/env bash set -euo pipefail # Create a virtualenvironment bazel run //:venv # Activate it (previous it was setting +e flag) source .venv/bin/activate # Some failing test -- users expects the script to end and fail here false # Some other command that doesn't fail true # !!!! Script returns 0 !!!! ```
1 parent a25b2cb commit 84f5644

File tree

3 files changed

+2
-6
lines changed

3 files changed

+2
-6
lines changed

py/tests/py_venv_image_layer/my_app_amd64_layers_listing.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2510,7 +2510,7 @@ files:
25102510
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/aspect_rules_py/py/tests/py_venv_image_layer/
25112511
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/aspect_rules_py/py/tests/py_venv_image_layer/.my_app_bin/
25122512
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/aspect_rules_py/py/tests/py_venv_image_layer/.my_app_bin/bin/
2513-
- -rwxr-xr-x 0 0 0 2853 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/aspect_rules_py/py/tests/py_venv_image_layer/.my_app_bin/bin/activate
2513+
- -rwxr-xr-x 0 0 0 2811 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/aspect_rules_py/py/tests/py_venv_image_layer/.my_app_bin/bin/activate
25142514
- -rwxr-xr-x 0 0 0 870664 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/aspect_rules_py/py/tests/py_venv_image_layer/.my_app_bin/bin/python
25152515
- -rwxr-xr-x 0 0 0 870664 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/aspect_rules_py/py/tests/py_venv_image_layer/.my_app_bin/bin/python3
25162516
- -rwxr-xr-x 0 0 0 870664 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/aspect_rules_py/py/tests/py_venv_image_layer/.my_app_bin/bin/python3.9

py/tests/py_venv_image_layer/my_app_arm64_layers_listing.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2491,7 +2491,7 @@ files:
24912491
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/aspect_rules_py/py/tests/py_venv_image_layer/
24922492
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/aspect_rules_py/py/tests/py_venv_image_layer/.my_app_bin/
24932493
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/aspect_rules_py/py/tests/py_venv_image_layer/.my_app_bin/bin/
2494-
- -rwxr-xr-x 0 0 0 2853 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/aspect_rules_py/py/tests/py_venv_image_layer/.my_app_bin/bin/activate
2494+
- -rwxr-xr-x 0 0 0 2811 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/aspect_rules_py/py/tests/py_venv_image_layer/.my_app_bin/bin/activate
24952495
- -rwxr-xr-x 0 0 0 743120 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/aspect_rules_py/py/tests/py_venv_image_layer/.my_app_bin/bin/python
24962496
- -rwxr-xr-x 0 0 0 743120 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/aspect_rules_py/py/tests/py_venv_image_layer/.my_app_bin/bin/python3
24972497
- -rwxr-xr-x 0 0 0 743120 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/aspect_rules_py/py/tests/py_venv_image_layer/.my_app_bin/bin/python3.9

py/tools/py/src/activate.tmpl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Adapted from CPython Lib/venv/scripts/common/activate
22

3-
set -eu -o pipefail
4-
53
deactivate () {
64
# reset old environment variables
75
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
@@ -84,5 +82,3 @@ export PATH
8482
# Call hash to forget past commands. Without forgetting
8583
# past commands the $PATH changes we made may not be respected
8684
hash -r 2> /dev/null
87-
88-
set +eu +o pipefail

0 commit comments

Comments
 (0)