You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[venv] Add a CLI flag to venv to use the pwd basename as the prompt #83082
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2020-01-14.23:57:53.719>created_at=<Date2019-11-23.22:28:34.409>labels= ['type-feature', 'library']
title='[venv] Add a CLI flag to venv to use the pwd basename as the prompt'updated_at=<Date2020-01-14.23:57:53.718>user='https://github.com/brettcannon'
I did a Twitter poll to see if there was consistent naming of the directory people created a virtual environment into when done locally to code (the answer is no). But a common theme was people not liking that the prompt defaults to the name of the directory that the virtual environment is in and seem to prefer for it to be os.path.basename(os.getcwd()).
Maybe it makes sense to add a --basename-prompt flag to set the prompt to the current working directory's basename?
being the equivalent of python3 -m venv --basename-prompt venv, but I'm not satisfied with the names (and it enforces using "venv" as a directory name)...
@vinay you got exactly what I mean. I had to actually teach a ton of people that shell trick with basename and pwd on Twitter, that trick doesn't seem to be something people know about, and yet a ton of people seem to be creating virtual environments with prompts manually specified like that.
Plus that trick varies from shell to shell and we already have enough issues just explaining to people how to activate between Windows and UNIX and then between even shells on the same OS.
So this is entirely for convenience.
@julien default directory names is an entirely separate topic as people can't agree on the default name (e.g. I prefer .venv as my default).
changed the title [-]Add a CLI flag to venv to use the pwd basename as the prompt[/-][+][venv] Add a CLI flag to venv to use the pwd basename as the prompt[/+]on Jan 6, 2020
New changeset 7d63780 by Vinay Sajip in branch 'master': bpo-38901: Allow setting a venv's prompt to the basename of the current directory. (GH-17946) 7d63780
Activity
brettcannon commentedon Nov 23, 2019
I did a Twitter poll to see if there was consistent naming of the directory people created a virtual environment into when done locally to code (the answer is no). But a common theme was people not liking that the prompt defaults to the name of the directory that the virtual environment is in and seem to prefer for it to be
os.path.basename(os.getcwd()).Maybe it makes sense to add a
--basename-promptflag to set the prompt to the current working directory's basename?vsajip commentedon Nov 24, 2019
What does this buy you beyond using
--prompt $(basename $PWD)
? Perhaps I'm not understanding what you're getting at - how about an example of what you mean?
JulienPalard commentedon Nov 24, 2019
I like the idea and I think I will use it!
As it's a bit long to type, I'm searching if other shorter variants could be usefull like:
being the equivalent of
python3 -m venv --basename-prompt venv, but I'm not satisfied with the names (and it enforces using "venv" as a directory name)...brettcannon commentedon Nov 25, 2019
@vinay you got exactly what I mean. I had to actually teach a ton of people that shell trick with basename and pwd on Twitter, that trick doesn't seem to be something people know about, and yet a ton of people seem to be creating virtual environments with prompts manually specified like that.
Plus that trick varies from shell to shell and we already have enough issues just explaining to people how to activate between Windows and UNIX and then between even shells on the same OS.
So this is entirely for convenience.
@julien default directory names is an entirely separate topic as people can't agree on the default name (e.g. I prefer
.venvas my default).vsajip commentedon Nov 26, 2019
Since there is already a --prompt available, I'd prefer a solution that allowed some special value(s) to be passed for this, e.g.
--prompt .
or perhaps
--prompt __curdir__
brettcannon commentedon Dec 8, 2019
If it were
.would we then always check if the prompt was a folder and then use the folder's name in that case? Or would it only apply to.?As for
__curdir__, it could work, but I don't know how easy would that be to remember or explain to new users compared to.?My vote is to support
.and make the rule that if you specify a folder it will use the basename automatically.[-]Add a CLI flag to venv to use the pwd basename as the prompt[/-][+][venv] Add a CLI flag to venv to use the pwd basename as the prompt[/+]brettcannon commentedon Jan 6, 2020
Any more feedback from anyone on the idea of using the basename of a directory if specified for
--prompt?vsajip commentedon Jan 14, 2020
New changeset 7d63780 by Vinay Sajip in branch 'master':
bpo-38901: Allow setting a venv's prompt to the basename of the current directory. (GH-17946)
7d63780
brettcannon commentedon Jan 14, 2020
Can this now be closed, Vinay?