Skip to content
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

Use uv for much faster Python virtual env creation #2279

Closed
rsyring opened this issue Jun 10, 2024 · 4 comments · Fixed by #2705
Closed

Use uv for much faster Python virtual env creation #2279

rsyring opened this issue Jun 10, 2024 · 4 comments · Fixed by #2705

Comments

@rsyring
Copy link

rsyring commented Jun 10, 2024

virtualenv and uv venv are much faster than python -m venv at creating virtual envs:

❯ time python -m venv python-demo           # 2.79 secs

❯ time pyvenv/bin/virtualenv venv-demo     #  224.15 millis

❯ time pyvenv/bin/uv venv uv-venv-demo  # 19.79 millis

I'm not sure how best to ensure those tools are installed and can be used. Should mise offer an "install command" type option (like tox) or just use uv or virtualenv if its on the path and assume the user is taking care of that? I'm inclined towards the latter and, if a user wants it to be more automatic, they should put their desired tool in default-python-packages or, as I would do, make it available using pipx.

@nickchomey
Copy link

nickchomey commented Jun 10, 2024

If this doesn't happen, you might consider using Rye, which is now developed by the same folks as uv and uses it under the hood. Their goal is to make the Rust cargo of python.

I wrote about how I got it working in mise here - you can just skip the mise python altogether. You might even say it is the mise of python!

@keybits
Copy link

keybits commented Aug 21, 2024

The 0.3 release of Uv incorporates much of the functionality of Rye (and the author of Rye is hoping for a future where Uv makes Rye redundant). (Mandatory mention: uV is written in Rust 😉 )

If Uv is becoming the best way to manage all things Python, it could be good for mise to make Uv the default approach as suggested above and add documentation to that effect.

@HipsterBrown
Copy link

Given the recent experiments with alternative "backends", it would be interesting to make one for uv as a first step.

@jdx
Copy link
Owner

jdx commented Aug 27, 2024

this should be pretty easy to do if someone wants to take it on, just add code here to use uv if it's on PATH:

let cmd = CmdLineRunner::new("python3")
.args(["-m", "venv", &venv.to_string_lossy()])
.envs(&env_vars)
.env(
PATH_KEY.to_string(),
env::join_paths(&path)?.to_string_lossy().to_string(),
);

Also put it behind a setting so people can opt-out.

@jdx jdx pinned this issue Sep 26, 2024
@jdx jdx closed this as completed in #2705 Oct 12, 2024
@jdx jdx unpinned this issue Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants