-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
automatic uv venv activation/creation #3211
Comments
Sharing what I have seen (having recently tried it) It's possible to use this to make [tools]
python = 'latest'
[env]
_.python.venv = { path = ".venv", create = true } # create the venv if it doesn't exist # mise automatically create the venv with uv
mise creating venv at: ~/Projects/test-python/.venv
Using CPython 3.13.0 interpreter at: ~/.local/share/mise/installs/python/3.13.0/bin/python
...
uv init # create the pyproject.toml (would also have created the venv)
uv add requests
uv run hello.py If I now delete the ❯ rm -rf .venv
mise creating venv at: ~/Projects/test-python/.venv
Using CPython 3.13.0 interpreter at: ~/.local/share/mise/installs/python/3.13.0/bin/python
Creating virtual environment at: .venv
Activate with: source .venv/bin/activate
❯ uv run hello.py
Installed 5 packages in 24ms
Hello from test-python! Note that ❯ rm -rf .venv
mise WARN no venv found at: ~/Projects/test-python/.venv
To create a virtualenv manually, run:
python -m venv ~/Projects/test-python/.venv
❯ uv run hello.py
Using CPython 3.13.0 interpreter at: /Users/hugues.verlin/.local/share/mise/installs/python/3.13.0/bin/python
Creating virtual environment at: .venv
Installed 5 packages in 12ms
Hello from test-python! I think it works quite well already. Probably, |
I'm still thinking it would be good default behavior. I imagine if you're in a uv project you probably want to activate the venv. |
Agree, having a setting that does not require one to add the There are things where it might clash now, like the There is also a |
thinking about this more, I'm leaning towards not the default but having a setting like
It appears uv respects 2 env vars which are relevant here:
We could probably read this if the integration is enabled, though I do know they also admonish not using |
It does unless the |
Right now if someone wants to use mise with uv they could do this (I think anyhow, as someone that doesn't write python):
.python-version:
mise.toml:
then they could run these commands:
I feel this is too many steps. I'm wondering if we could automate all of this. If we see there is a
uv.lock
file, we could automatically calluv venv
to create the venv, and set VIRTUAL_ENV/PATH based on that new venv. Basically remove needing to put this intomise.toml
and also not make the user manually create the venv.cc @charliermarsh, would welcome any thoughts on how best to integrate with uv
The text was updated successfully, but these errors were encountered: