• 3 Posts
  • 444 Comments
Joined 1 year ago
cake
Cake day: July 7th, 2023

help-circle




  • I’m sure I’m not the only person who’s got uv configured to install the virtualenv in the local .venv folder

    That’s the default for projects. Script is a different run mode.

    every time I invoke the script, I’d get a new set of dependencies installed wherever I happen to be.

    Does that happen though? uv uses the cache location for these script dependencies, not your usual venv one. Where you call it from is not a factor.






  • yeah, all that setup sucks even after being writing python for years.

    Nowadays I’ve been running every project with uv and it’s a much better and faster experience, usually in 3 steps: 1. initialize, 2. add dependencies, 3. run project:

    
    # if the project doesn't already have a pyproject.toml with dependencies, initialize it
    # uv will also install the right interpreter if not present:
    uv init --python 3.13
    
    # anything you would install with pip, use uv add:
    uv add dep1 dep2
    
    # run the project / script
    uv run main.py
    
    

    Then in future runs (as long as you have the pyproject.toml), you can just do uv run main.py (shorthand to uv run python main.py), even when there’s no venv created. No more activating virtual envs. No more long interpreter installations. No more accidentally messing with system’s packages or the PATH variable. With the uv.lock that’s also a lot more reliable to reproduce than requirements.txt and similar.






  • The Python env has been trying this multiple tools approach for decades and consistently delivering a worse experience than languages that pack most things in one tool.

    Rust is a bliss to use, largely thanks to cargo that takes care of build, dependencies, locking, tests, publishing etc. You say do one thing and do it well. In my experience they often do one thing in a mediocre way, while forcing users to understand which and how to combine dozens of possible tools in a development environment that keeps changing. It’s messy, slow, error prone, and requires constant developer attention.