mirror of https://github.com/python/cpython
gh-89427: Set VIRTUAL_ENV_PROMPT even when VIRTUAL_ENV_DISABLE_PROMPT… (GH-106643)
This commit is contained in:
parent
ab86426a34
commit
af51bd7cda
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Set the environment variable ``VIRTUAL_ENV_PROMPT`` at :mod:`venv`
|
||||
activation, even when ``VIRTUAL_ENV_DISABLE_PROMPT`` is set.
|
Loading…
Reference in New Issue