classification
Title: Set a environment variable for venv prompt
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Anthony Sottile, batisteo, vinay.sajip, xtreak
Priority: normal Keywords: patch

Created on 2018-11-27 16:12 by batisteo, last changed 2019-01-05 05:42 by xtreak.

Pull Requests
URL Status Linked Edit
PR 10745 open batisteo, 2018-11-27 16:25
Messages (4)
msg330533 - (view) Author: Baptiste Darthenay (batisteo) * Date: 2018-11-27 16:12
When creating a new virtual env with `python3 -m venv .venv --prompt env`, the prompt information is only used to set a temporary PS1.

This information is lost when using custom prompt, for example with ZSH.

I propose to set VIRTUAL_ENV_PROMPT=__VENV_PROMPT__ when activating the newly created venv, to be used by tools and other shells.
msg330542 - (view) Author: Anthony Sottile (Anthony Sottile) * Date: 2018-11-27 17:55
The current prompt works fine for me on zsh -- what's the bug here?

zsh $ virtualenv venv --prompt '(wat)'
Using real prefix '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7'
New python executable in /private/tmp/venv/bin/python3.7
Also creating executable in /private/tmp/venv/bin/python
Installing setuptools, pip, wheel...done.
zsh $ . venv/bin/activate
(wat)zsh $
msg330548 - (view) Author: Baptiste Darthenay (batisteo) * Date: 2018-11-27 18:49
How the venv prompt name would be displayed in a project like Powerline?

Or in VS Code? https://i.ibb.co/JHYrnk2/Screenshot-from-2018-11-27-19-41-47.png

Or in my custom prompt? https://gist.github.com/batisteo/c5c9bd87a344cdbfb7a6401648c118a2#file-batisteo-zsh-theme-L194
msg333043 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python triager) Date: 2019-01-05 05:42
issue34439 seems like a similar proposal. I am adding @vinay.sajip. Since this seems like a new feature I have removed 3.7 from the version list.
History
Date User Action Args
2019-01-05 05:42:56xtreaksetversions: - Python 3.7
nosy: + vinay.sajip, xtreak

messages: + msg333043

components: + Library (Lib)
type: enhancement
2018-11-27 18:49:37batisteosetmessages: + msg330548
2018-11-27 17:55:11Anthony Sottilesetnosy: + Anthony Sottile
messages: + msg330542
2018-11-27 16:25:05batisteosetkeywords: + patch
stage: patch review
pull_requests: + pull_request9992
2018-11-27 16:12:29batisteocreate