uv
uv copied to clipboard
Request: Support uv venv --prompt
Hi,
venv
has an mainly undocumented feature :
$ python3.9 -m venv --prompt=<my prompt> ./venv
This command creates the virtuelenv, and append a prompt parameter ti the pyvenv.cfg
file :
$ cat ./venv/pyvenv.cfg
home = /usr/local/bin
include-system-site-packages = false
version = 3.9.16
prompt = '<my prompt>'
This option is useful when you use several virtualenvs, as the active venv prompt can be displayed by the (linux) prompt, like liquidprompt or starship
Thanks !
I second this. I use --prompt
a lot because I have lots of projects. It is easy to forget to deactivate when moving from one to the other. Just seeing (.venv) reinout@mycomputer:~/some/project/ $
doesn't help to spot the difference.
(Note that I suspect there are nicer ways to handle it and perhaps uv
could make the prompt default to the directory name etc.... but the idea at the moment is probably to keep everything the same and just mimick pip/venv as good as possible :-) So supporting --prompt
is good enough for now.)
Please support --prompt .
and make it as a default behavior.
I use this alias for daily job.
alias mkvenv='python3 -m venv --prompt . .venv
I believe we discussed this multiple times internally, not sure why it didn't happen.
I'm also on a mac, which matches your observation. I'd guess we can expect the same behaviour on linux. So: windows by default does the "right" thing?
I'm also on a mac, which matches your observation. I'd guess we can expect the same behaviour on linux. So: windows by default does the "right" thing?
@reinout I was just double checking Windows to add some more info for the PR which is waiting to be merged, when I realised that my comment was incorrect. In my case the venv prompt I was seeing was coming from ohmyposh.
If I run (for example) the old version of Powershell (where I don't have ohmyposh set up) the prompt defaults to the name you gave to the venv (which we know defaults to .venv)
Apologies for the confusion.
If I read #1570 correctly, the upcoming behaviour is that uv venv
even automatically sets the prompt to the name of the current directory (instead of .venv
)? That's extra luxurious 👍 Then I won't even need --prompt
.
@reinout Yes, that's correct. All thanks to @methane for the idea and the PR :)