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, brett.cannon, lys.nikolaou, vinay.sajip, xtreak
Priority: normal Keywords: patch

Created on 2018-11-27 16:12 by batisteo, last changed 2019-05-23 21:00 by brett.cannon.

Pull Requests
URL Status Linked Edit
PR 10745 open batisteo, 2018-11-27 16:25
Messages (8)
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.
msg342860 - (view) Author: Lysandros Nikolaou (lys.nikolaou) * Date: 2019-05-19 14:28
Is anybody still working on this?
msg343325 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2019-05-23 20:49
@lys.nikolaou it looks like there was an initial PR, but it only updated things for Bash and not for all the other shells that we support for virtual environments.
msg343327 - (view) Author: Lysandros Nikolaou (lys.nikolaou) * Date: 2019-05-23 20:55
@brettcannon, yeah I saw that, but there hasn't been any progress since November. I'm still interested in this though. What would the correct workflow be? Pushing commits to the same PR or opening a new one with a co-author?
msg343328 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2019-05-23 21:00
You can open a new PR with co-author or basing off of their fork if it's still around.
History
Date User Action Args
2019-05-23 21:00:26brett.cannonsetmessages: + msg343328
2019-05-23 20:55:25lys.nikolaousetmessages: + msg343327
2019-05-23 20:49:07brett.cannonsetnosy: + brett.cannon
messages: + msg343325
2019-05-19 14:28:21lys.nikolaousetmessages: + msg342860
2019-05-19 14:26:29lys.nikolaousetnosy: + lys.nikolaou
2019-05-19 14:25:41xtreaklinkissue36966 superseder
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