I switched to hatch last year for many projects, its been quite pleasant. Has anyone used both hatch and uv, and could comment on that comparison? EDIT: quick google gives me these opinions[1] [1]: https://www.reddit.com/r/Python/comments/1gaz3tm/hatch_or_uv...
Switching from Pyenv to Uv
171–180 of 239 posts
Re: Switching from Pyenv to Uv
#172Earlier quoted context omitted.
The install speed alone makes it worthwhile for me. It went from minutes to seconds.
I was working on a Raspberry Pi at a hackathon, and pip install was eating several minutes at a time. Tried uv for the first time and it was down to seconds.
Re: Switching from Pyenv to Uv
#173has 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 worked in a large-ish org where 20+ python projects, their CI/CD pipelines and their docker images were migrated from `pyenv` + `.python-version` + `requirements.txt` to `uv` in basically a single day. If you are comfortable with `pyenv`, the switch to `uv` is basically a walk in the park. The benefit is the speed + the predictable dependencies resolution.
Re: Switching from Pyenv to Uv
#174For scripting... HIGHLY recommend putting your dependencies inline. E.g.: #!/usr/bin/env python3 # /// script # requires-python = ">=3.11" # dependencies = [ # "psycopg2-binary", # "pyyaml", # ] # /// Then - uv run -s file.py
Do you need a wrapper script for scripts in the PATH or execve? I would usualy chmod+x the script but I am not sure here.
> Using uv as your shebang line
— https://news.ycombinator.com/item?id=42855258
Since `env` doesn’t pass multiple arguments by default, the suggested line uses `-S`:
#!/usr/bin/env -S uv run --scriptRe: Switching from Pyenv to Uv
#175Earlier quoted context omitted.
Agree. I mostly do front end in my day job, and despite JavaScript being a bit of a mess lang, dealing with npm is way better than juggling anaconda, miniforge, Poetry, pip, venv, etc depending on the project. UV is such a smooth UX that it makes you wonder how something like it wasn’t part of Python from the start.
More importantly, migrating from npm, to pnpm, to yarn, to bun, is very nearly seamless. Migrating in the Python ecosystem? Not anywhere close.
Re: Switching from Pyenv to Uv
#176Earlier quoted context omitted.
I generally agree but one thing I find very frustrating (i.e. have not figured out yet) is how deal with extras well, particularly with pytorch. Some of my machines have GPU, some don't and things like "uv add" end up uninstalling everything and installing the opposite forcing a resync with the appropriate --extra tag. The examples in the docs do things like CPU on windows and GPU on Linux but all my boxes are linux.…
Getting the right version of PyTorch installed to have the correct kind of acceleration on each different platform you support has been a long-standing headache across many Python dependency management tools, not just uv. For example, here's the bug in poetry regarding this issue: https://github.com/python-poetry/poetry/issues/6409 As I understand it, recent versions of PyTorch have made this process somewhat easier,…
Re: Switching from Pyenv to Uv
#177Re: Switching from Pyenv to Uv
#178Earlier quoted context omitted.
Usually the VENV and import lines are enough
How do you determine where the venv is? AFAIK, uv run in script mode creates the venv in some random temporary directory.
import os
print(os.environ['VIRTUAL_ENV'] + '/bin/python')
Then, e.g. in VS Code, you bring up the command palette, run Python: Select Interpreter, and enter the result.Re: Switching from Pyenv to Uv
#179Re: Switching from Pyenv to Uv
#180Earlier quoted context omitted.
Agree. I mostly do front end in my day job, and despite JavaScript being a bit of a mess lang, dealing with npm is way better than juggling anaconda, miniforge, Poetry, pip, venv, etc depending on the project. UV is such a smooth UX that it makes you wonder how something like it wasn’t part of Python from the start.
Feels like you're doing it wrong if you're dealing with all of those.