-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
Summary
With venv:
$ python3 -m venv .venv --prompt base
$ source .venv/bin/activate
$ echo "'$VIRTUAL_ENV_PROMPT'"
'base'
$ deactivate
With virtualenv:
$ uvx virtualenv .venv --prompt base
$ source .venv/bin/activate
$ echo "'$VIRTUAL_ENV_PROMPT'"
'base'
$ deactivate
With uv:
$ uv venv --prompt base
$ source .venv/bin/activate
$ echo "'$VIRTUAL_ENV_PROMPT'"
'(base) '
$ deactivate
uv adds parenthesis and a trailing space to VIRTUAL_ENV_PROMPT, while venv and virtualenv do not. Also, without --prompt base, all 3 cases above differ in the following way: venv and virtualenv yield '.venv' and uv yields '(pwd) ' where pwd is the current directory name.
Just calling out the differences to make sure which ones are intentional. I'd argue adding the parenthesis and the trailing space to VIRTUAL_ENV_PROMPT might be differing too much from the other tools and confusing for scripts that want to use the value of this environment value. A typical case is setting VIRTUAL_ENV_DISABLE_PROMPT=1 and then using $VIRTUAL_ENV_PROMPT when rendering a custom shell prompt.
Also, I see the 3 tools above set the prompt in .venv/pyvenv.cfg the same way (no parenthesis and no trailing space), so maybe another argument in favor of keeping VIRTUAL_ENV_PROMPT also the same.
Platform
macOS 15 arm64
Version
uv 0.7.3 (Homebrew 2025-05-07)
Python version
Python 3.12.9