This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Making venv activation script prompts consistent
Type: behavior Stage: resolved
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: 37660 37661 Superseder:
Assigned To: Nosy List: brett.cannon, vinay.sajip
Priority: low Keywords: patch

Created on 2019-07-23 20:41 by brett.cannon, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 14941 merged brett.cannon, 2019-07-24 22:26
Messages (2)
msg348355 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2019-07-23 20:41
There are five activation scripts and they are all do things differently when it comes to prompt manipulation. Standardizing on one set of semantics would probably be good for consistency and so people know what to expect regardless of their shell.

Currently the various semantics are as follows (see subdirectories in https://github.com/python/cpython/tree/master/Lib/venv/scripts for the code):

- PowerShell: use __VENV_PROMPT__, make it green
- bash: use __VENV_PROMPT__ if defined (which is nearly true; bpo-37661), else if virtual env in a directory named "__" (for some defunked software named Aspen; bpo-37660) then use "[dir]", else "(dir)"
- Command Prompt: use __VENV_PROMPT__
- csh: use __VENV_NAME__ if defined, else calculate name and use "[dir]"
- fish: same as bash, except if not using __VENV_PROMPT__ then use white text on a blue background

So the variances/questions are:
1. Always use __VENV_PROMPT__ and don't bother testing? (bpo-37661 suggests we should, or else come up with a new way to tell whether a custom prompt was provided)
2. Always use colour regardless of whether the prompt is custom? (I vote "yes"; don't care about what the colours happen to be)
3. Parentheses or square brackets? (Due to bpo-37661 I vote for parentheses since that's what people are used to)
msg350127 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2019-08-21 22:58
New changeset 48ede6b8f685669f53d26ae8456647af42ae3dae by Brett Cannon in branch 'master':
bpo-37663: have venv activation scripts all consistently use __VENV_PROMPT__ for prompt customization (GH-14941)
https://github.com/python/cpython/commit/48ede6b8f685669f53d26ae8456647af42ae3dae
History
Date User Action Args
2022-04-11 14:59:18adminsetgithub: 81844
2019-08-22 17:52:43brett.cannonsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-08-21 22:58:05brett.cannonsetmessages: + msg350127
2019-07-24 22:26:02brett.cannonsetkeywords: + patch
stage: patch review
pull_requests: + pull_request14713
2019-07-23 20:41:48brett.cannonsetdependencies: + Drop support for Aspen magic directories in venv's activate scripts, venv activation scripts erroneously check if __VENV_PROMPT__ is defined
2019-07-23 20:41:20brett.cannonsetpriority: normal -> low
2019-07-23 20:41:06brett.cannoncreate