Skip to content

Commit

Permalink
gh-89427: Set VIRTUAL_ENV_PROMPT even when VIRTUAL_ENV_DISABLE_PROMPT… (
Browse files Browse the repository at this point in the history
  • Loading branch information
jimporter authored and pull[bot] committed Aug 23, 2023
1 parent 320cea5 commit 079cec4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Lib/venv/scripts/common/Activate.ps1
Expand Up @@ -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'"
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions Lib/venv/scripts/common/activate
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Lib/venv/scripts/posix/activate.csh
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Lib/venv/scripts/posix/activate.fish
Expand Up @@ -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
Expand Down Expand Up @@ -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.

0 comments on commit 079cec4

Please sign in to comment.