Live data from Hacker News

Switching from Pyenv to Uv

bluesock.org

121–130 of 239 posts

Re: Switching from Pyenv to Uv

#121
post #83

Uv really fixes Python. It takes it from "oh god I have to fight Python again" to "wow it was actually fast and easy". I think all the other projects (pyenv, poetry, pip, etc.) should voluntarily retire for the good of Python. If everyone moved to Uv right now, Python would be in a far better place. I'm serious. (It's not going to happen though because the Python community has no taste.) The only very minor issue I'v…

Strong agree. The respectful act of other package managers would be consider themselves deprecated and point to uv instead.

The risk is obviously uv losing funding. I kinda hope the PSF has thought about this and has a contingency plan for uv winning and dying/becoming enshittified soon after.

Re: Switching from Pyenv to Uv

#122

frankly the only pain point i have working with uv is that it's too new for the LLMs to know about it

What do LLMs have to do with package and project management?

Some people are too lazy to read docs, so they ask the bullshit generators instead.

Re: Switching from Pyenv to Uv

#123

For 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.

Not at a laptop to try this right now, but shouldn't this be possible with the shebang? Something along the lines of:

    #!/home/tetha/Tools/uv run

Re: Switching from Pyenv to Uv

#124

What does uv offer over bog-standard setuptools, pip, pip-tools, and build? Right now, the only thing I really want is dependency pinning in wheels but not pyproject.yaml, so I can pip install the source and get the latest and greatest, or I can pip install a wheel and get the frozen dependencies I used to build the wheel. Right now, if I want the second case, I have to publish the requirements.txt file and add the w…

It does everything with less surprises and faster. Just try it.

Re: Switching from Pyenv to Uv

#125

The functionalities of three tooling projects, namely uv, ruff (linter), and pyright (type checker) need to merge and become mandatory for new Python projects. Together they will bring some limited sanity to Python.

i believe there is a type checker branch on ruff git

Currently known as red-knot:

https://github.com/astral-sh/ruff/milestone/20

Re: Switching from Pyenv to Uv

#126
post #123

Earlier quoted context omitted.

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.

Not at a laptop to try this right now, but shouldn't this be possible with the shebang? Something along the lines of: #!/home/tetha/Tools/uv run

Yes it is, I just converted my work scripts over this afternoon.

    #!/usr/bin/env uv run

Re: Switching from Pyenv to Uv

#127

For 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.

If you want to make it work regardless of where uv is installed, you can use the following shebang line:

  #!/usr/bin/env uv run --script

Re: Switching from Pyenv to Uv

#128

Uv really fixes Python. It takes it from "oh god I have to fight Python again" to "wow it was actually fast and easy". I think all the other projects (pyenv, poetry, pip, etc.) should voluntarily retire for the good of Python. If everyone moved to Uv right now, Python would be in a far better place. I'm serious. (It's not going to happen though because the Python community has no taste.) The only very minor issue I'v…

True. I had to give up on mypy and move to pyright because mypy uses pip to install missing types and they refuse to support uv. In the CI pipeline where I use UV, I don't have a pip installed so mypy complains about missing pip. Of course I can do it by myself by adding typing pkgs to requirement.txt file then what's the point of devtools! And I don't want requirements.txt when I already got pyproject.toml. Once you…

Pyright is waaay better than Mypy anyway so I'd say they did you a favour.

Re: Switching from Pyenv to Uv

#129
post #118
post #108

Earlier quoted context omitted.

Yes, uv is well suited to that use case by declaring your Python version and/or dependencies right in the script itself: https://docs.astral.sh/uv/guides/scripts/#declaring-script-d... You can use an alternate shebang line so you can run the script directly: #!/usr/bin/env -S uv run --script # /// script # requires-python = ">=3.12" # dependencies = [ # "requests", # "typer-slim", # ] # /// import requests import typ…

Yes but I then still then have to declare all dependencies for all tiny throwaway script, right now I have global python in pyenv and installed tons of plugins and didn't have too much issues with conflicts so was good enough for me

How about just install a python version with uv and install everything into that?

Or better, do the above, then create a virtual env, set the virtual env in your.bashrc and install everything into that

Better still... use uv script --init See other comments on this post

Post reply on HN