summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Porter <826865+jimporter@users.noreply.github.com>2023-07-13 06:08:33 (GMT)
committerGitHub <noreply@github.com>2023-07-13 06:08:33 (GMT)
commitaf51bd7cda9c0cba149b882c1e501765595e5fc3 (patch)
treefb6468d6b168373832488dbff0dbc14cb26721ce
parentab86426a3472ab68747815299d390b213793c3d1 (diff)
downloadcpython-af51bd7cda9c0cba149b882c1e501765595e5fc3.zip
cpython-af51bd7cda9c0cba149b882c1e501765595e5fc3.tar.gz
cpython-af51bd7cda9c0cba149b882c1e501765595e5fc3.tar.bz2
gh-89427: Set VIRTUAL_ENV_PROMPT even when VIRTUAL_ENV_DISABLE_PROMPT… (GH-106643)
-rw-r--r--Lib/venv/scripts/common/Activate.ps13
-rw-r--r--Lib/venv/scripts/common/activate5
-rw-r--r--Lib/venv/scripts/posix/activate.csh2
-rw-r--r--Lib/venv/scripts/posix/activate.fish2
-rw-r--r--Misc/NEWS.d/next/Library/2023-07-11-12-34-04.gh-issue-89427.GOkCp9.rst2
5 files changed, 9 insertions, 5 deletions
diff --git a/Lib/venv/scripts/common/Activate.ps1 b/Lib/venv/scripts/common/Activate.ps1
index eeea358..d75b8fb 100644
--- a/Lib/venv/scripts/common/Activate.ps1
+++ b/Lib/venv/scripts/common/Activate.ps1
@@ -219,6 +219,8 @@ deactivate -nondestructive
# that there is an activated venv.
$env:VIRTUAL_ENV = $VenvDir
+$env:VIRTUAL_ENV_PROMPT = $Prompt
+
if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
Write-Verbose "Setting prompt to '$Prompt'"
@@ -233,7 +235,6 @@ if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
_OLD_VIRTUAL_PROMPT
}
- $env:VIRTUAL_ENV_PROMPT = $Prompt
}
# Clear PYTHONHOME
diff --git a/Lib/venv/scripts/common/activate b/Lib/venv/scripts/common/activate
index 408df5c..458740a 100644
--- a/Lib/venv/scripts/common/activate
+++ b/Lib/venv/scripts/common/activate
@@ -52,6 +52,9 @@ _OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/__VENV_BIN_NAME__:$PATH"
export PATH
+VIRTUAL_ENV_PROMPT="__VENV_PROMPT__"
+export VIRTUAL_ENV_PROMPT
+
# unset PYTHONHOME if set
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
# could use `if (set -u; : $PYTHONHOME) ;` in bash
@@ -64,8 +67,6 @@ if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
_OLD_VIRTUAL_PS1="${PS1:-}"
PS1="__VENV_PROMPT__${PS1:-}"
export PS1
- VIRTUAL_ENV_PROMPT="__VENV_PROMPT__"
- export VIRTUAL_ENV_PROMPT
fi
# This should detect bash and zsh, which have a hash command that must
diff --git a/Lib/venv/scripts/posix/activate.csh b/Lib/venv/scripts/posix/activate.csh
index 5e8d66f..9caf138 100644
--- a/Lib/venv/scripts/posix/activate.csh
+++ b/Lib/venv/scripts/posix/activate.csh
@@ -13,13 +13,13 @@ setenv VIRTUAL_ENV "__VENV_DIR__"
set _OLD_VIRTUAL_PATH="$PATH"
setenv PATH "$VIRTUAL_ENV/__VENV_BIN_NAME__:$PATH"
+setenv VIRTUAL_ENV_PROMPT "__VENV_PROMPT__"
set _OLD_VIRTUAL_PROMPT="$prompt"
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
set prompt = "__VENV_PROMPT__$prompt"
- setenv VIRTUAL_ENV_PROMPT "__VENV_PROMPT__"
endif
alias pydoc python -m pydoc
diff --git a/Lib/venv/scripts/posix/activate.fish b/Lib/venv/scripts/posix/activate.fish
index 91ad644..565df23 100644
--- a/Lib/venv/scripts/posix/activate.fish
+++ b/Lib/venv/scripts/posix/activate.fish
@@ -37,6 +37,7 @@ set -gx VIRTUAL_ENV "__VENV_DIR__"
set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV/__VENV_BIN_NAME__" $PATH
+set -gx VIRTUAL_ENV_PROMPT "__VENV_PROMPT__"
# Unset PYTHONHOME if set.
if set -q PYTHONHOME
@@ -65,5 +66,4 @@ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
end
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
- set -gx VIRTUAL_ENV_PROMPT "__VENV_PROMPT__"
end
diff --git a/Misc/NEWS.d/next/Library/2023-07-11-12-34-04.gh-issue-89427.GOkCp9.rst b/Misc/NEWS.d/next/Library/2023-07-11-12-34-04.gh-issue-89427.GOkCp9.rst
new file mode 100644
index 0000000..1605920
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2023-07-11-12-34-04.gh-issue-89427.GOkCp9.rst
@@ -0,0 +1,2 @@
+Set the environment variable ``VIRTUAL_ENV_PROMPT`` at :mod:`venv`
+activation, even when ``VIRTUAL_ENV_DISABLE_PROMPT`` is set.