uv
uv copied to clipboard
Support `venv --prompt`
trafficstars
Summary
- Add
--promptoption tovenv --prompt .(default) uses current directory name
Fixes #1445
Test Plan
This is my first Rust code and I don't know how to write tests yet. I just checked the behavior manually:
$ cargo build
$ mkdir t
$ cd t
$ ../target/debug/uv venv -p 3.11
$ rg -w t .venv/bin/acti*
.venv/bin/activate.csh
13:setenv VIRTUAL_ENV '/Users/inada-n/work/uv/t/.venv'
20:if ('t' != "") then
21: setenv VIRTUAL_ENV_PROMPT 't'
23: setenv VIRTUAL_ENV_PROMPT "$VIRTUAL_ENV:t:q"
38: # in which case, $prompt is undefined and we wouldn't
.venv/bin/activate
48:VIRTUAL_ENV='/Users/inada-n/work/uv/t/.venv'
59: VIRTUAL_ENV_PROMPT="t"
.venv/bin/activate.fish
61:set -gx VIRTUAL_ENV '/Users/inada-n/work/uv/t/.venv'
73:if test -n 't'
74: set -gx VIRTUAL_ENV_PROMPT 't'
.venv/bin/activate.ps1
40:if ("t" -ne "") {
41: $env:VIRTUAL_ENV_PROMPT = "t"
.venv/bin/activate.nu
6:# but then simply `deactivate` won't work because it is just an alias to hide
35: let virtual_env = '/Users/inada-n/work/uv/t/.venv'
50: let virtual_env_prompt = (if ('t' | is-empty) {
53: 't'
Also congrats on your first Rust pull request ❤️
When name is specified
~/work/uv/t (git)-[support-prompt] % ../target/debug/uv venv -p 3.11 hoge
Using Python 3.11.7 interpreter at /opt/homebrew/opt/[email protected]/bin/python3.11
Creating virtualenv at: hoge
~/work/uv/t (git)-[support-prompt] % grep prompt hoge/pyvenv.cfg
prompt = hoge
When name is omitted (.venv)
~/work/uv/t (git)-[support-prompt] % ../target/debug/uv venv -p 3.11
Using Python 3.11.7 interpreter at /opt/homebrew/opt/[email protected]/bin/python3.11
Creating virtualenv at: .venv
~/work/uv/t (git)-[support-prompt] % grep prompt .venv/pyvenv.cfg
prompt = t
Nice. We now also support batch files. Could you add the same logic to the activation.bat file?
@methane Thanks a lot for initiating this effort! I made some small tweaks at the end to accommodate Micha's recommendation:
- Expanding the CLI flag documentation
- Using a custom enum
Prompt - Updated the PR description to list down the workflow
Congrats on landing your first PR and welcome to Astral! 🥳
Great job guys !