Hacker News new | ask | show | jobs
by 6ak74rfy 363 days ago
UV is fast, like FAST. Plus, it removes the need for pyenv (for managing different Python versions) and pip for me. Plus, no need to activate env or anything, `uv run ...` automatically runs your code through the env.

It's a nice software.

1 comments

> Plus, it removes the need for pyenv

I don't see a way to change current and global versions of python/venvs to run scripts, so that when I type "python" it uses that, without making an alias.

Two options other than aliases:

1. Modify your PATH:

    export PATH="$(uv run python -BISc 'import sys; print(sys.base_exec_prefix)')/bin:$PATH"
2. Put this in an executable file called "python" early in your PATH:

    #!/bin/sh
    exec uv run python $*
Those are basically what pyenv does (via a symlink and PATH entry).

The second option will always pick up the Python local to the project directory you're in, if any. The former (if you put it in your shell profile) will not.

If they're your scripts (i.e. your writing/editing them) then you can declare dependencies following the PEP723 format and uv will respect that.

https://docs.astral.sh/uv/guides/scripts/#declaring-script-d...

> uv run example.py

I specifically want to run "python", rather subcommands for some other command, since I often I want to pass in arguments to the python interpreter itself, along with my script.

You can use "uv run python script.py" to the same effect.
> I don't see a way to change current and global versions of python

You really shouldn't be doing this. Utilities on your host rely on the system python being stable, unchanged, pinned to a very specific python version; also with exact versions for dependencies.

For example in fedora/rhel, changing the default platform-python will prevent you from using yum/dnf to apply system updates.

Utilities on my host that require system python won't use /usr/bin/env python.