Live data from Hacker News

Switching from Pyenv to Uv

bluesock.org

11–20 of 239 posts

Re: Switching from Pyenv to Uv

#11
post #2

has anybody doing complex projects achiever success with uv completely replacing pyenv, and had mostly pros and few or no cons? I'm very comfortable with pyenv, but am extremely open to new stuff

I don't know how complex your project is but I moved my previous work from pyenv to rye(UV and rye have merged, most work is being done on uv, today I'd probably use UV)

And am currently trying to move current work to UV. The problems seem to be possibility of unknown breakage for unknown users of the old project not any known technical issue.

I'd highly reccomend UV. Its just easier/more flexible. And it downloads third party pre compiled python builds instead of the extra time and complexity to get it compiling locally. Its much nicer especially when maintaing an environment for a team that just works without them having to know about it

One downside of UV is that unlike pyenv and rye it doesn't shim python. Pyenv shim did give me some trouble but rye simples shim didn't. The workaround is to run stuff with uv run x.py instead of python x.py

Re: Switching from Pyenv to Uv

#12

Earlier quoted context omitted.

If the libraries are meant to be used together, you can get away with one venv. If they should be decoupled, then one venv per lib is better. There is not much to know: - uv python install if you want a particular version of python to be installed - uv init --vcs none [--python ] in each directory to initialize the python project - uv add [--dev] to add libraries to your venv - uv run when you want to run a command i…

There's also workspaces ( https://docs.astral.sh/uv/concepts/projects/workspaces/ ) if you have common deps and it's possible to act on a specific member of the workspace as well.

That's one of the bonus I was thinking about. It's nice if you have a subset of deps you want to share, or if one dep is actually part of the monorepo, but it does require more to know.

Re: Switching from Pyenv to Uv

#13
15 year Python dev who usually adopts tooling slowly. Just do it, uv's absolutely worth it.

I also use mise with it, which is a great combination and gives you automatic venv activation among other things.

See, among other mise docs related to Python, https://mise.jdx.dev/mise-cookbook/python.html

See also a Python project template I maintain built on mise + uv: https://github.com/level12/coppy

Re: Switching from Pyenv to Uv

#15
I highly, highly recommend uv. It solves & installs dependencies incredibly fast, and the CLI is very intuitive once you've memorized a couple commands. It handles monorepos well with the "workspaces" concept, it can replace pipx with "uv tool install," handle building & publishing, and the docker image is great, you just add a FROM line to the top and copy the bin from /uv.

I've used 'em all, pip + virtualenv, conda (and all its variants), Poetry, PDM (my personal favorite before switching to uv). Uv handles everything I need in a way that makes it so I don't have to reach for other tools, or really even think about what uv is doing. It just works, and it works great.

I even use it for small scripts. You can run "uv init --script " and then "uv add package1 package2 package3 --script ". This adds an oddly formatted comment to the top of the script and instructs uv which packages to install when you run it. The first time you run "uv run ," uv installs everything you need and executes the script. Subsequent executions use the cached dependencies so it starts immediately.

If you're going to ask me to pitch you on why it's better than your current preference, I'm not going to do that. Uv is very easy to install & test, I really recommend giving it a try on your next script or pet project!

Re: Switching from Pyenv to Uv

#16
post #13

15 year Python dev who usually adopts tooling slowly. Just do it, uv's absolutely worth it. I also use mise with it, which is a great combination and gives you automatic venv activation among other things. See, among other mise docs related to Python, https://mise.jdx.dev/mise-cookbook/python.html See also a Python project template I maintain built on mise + uv: https://github.com/level12/coppy

I used to install Python through mise but now I just use uv tbh.

Re: Switching from Pyenv to Uv

#17
post #13

15 year Python dev who usually adopts tooling slowly. Just do it, uv's absolutely worth it. I also use mise with it, which is a great combination and gives you automatic venv activation among other things. See, among other mise docs related to Python, https://mise.jdx.dev/mise-cookbook/python.html See also a Python project template I maintain built on mise + uv: https://github.com/level12/coppy

I used to install Python through mise but now I just use uv tbh.

Similar. But we get other benefits through mise, like tasks and other tool installs (e.g. Terraform). So we still use them together.

Re: Switching from Pyenv to Uv

#18
post #17

Earlier quoted context omitted.

I used to install Python through mise but now I just use uv tbh.

Similar. But we get other benefits through mise, like tasks and other tool installs (e.g. Terraform). So we still use them together.

That's fair, it's also nice if you have a backend in Python and a frontend in JS since mise also handles node.

Re: Switching from Pyenv to Uv

#19
post #17

Earlier quoted context omitted.

Similar. But we get other benefits through mise, like tasks and other tool installs (e.g. Terraform). So we still use them together.

That's fair, it's also nice if you have a backend in Python and a frontend in JS since mise also handles node.

Forgot about that! Yes, another significant benefit of why we use mise.

In particular, we use flask-vite and it's so nice to be able to have the right version of Node specified in the same management system as we specify the Python version. This solved a not insignificant amount of angst around FE development for me personally since I spend most of my time in the BE.

It's not like it was insurmountable before. But now, with mise, it's in that "just works" category for me.

Post reply on HN