Remix.run Logo
strangelove026 2 hours ago

UV has done so much for Python but I did fight it a bit today.

I was trying to centralize the management of a script that appears in a few different repos, and has invariably drifted in its implementation in multiple way over time.

My idea was

uv run --with $package main --help

I was looking for an easy way to automatically

1. Install it if it doesn’t exist and run 2. Don’t install it if it’s running the latest version 3. Update if it’s not on the latest version

All three were surprisingly tricky to accomplish.

By default uv run will reinstall it every time. Which is 6 seconds of venv and installs

uvx or uv tool weren’t much better as that posed new problems where a user wouldn’t get upgrades.

I ended up having the script run a paginated GET on codeartifact and update if there’s a newer non-dev version (and then re-execute).

That seems to work. And 200ms delay is better than 6 seconds. But it wasn’t quite the experience I wanted.

fletchowns an hour ago | parent | next [-]

> uvx or uv tool weren’t much better as that posed new problems where a user wouldn’t get upgrades.

Couldn't the user just run `uv tool upgrade <tool_name>`?

strangelove026 an hour ago | parent [-]

That command takes 6 seconds I believe as well if I remember correctly. And likely there isn’t a ton of churn on the script. So having it make a new venv each time is kind of annoying. I was trying to aim for a good balance of fast and developer experience.

Basically if there’s an upgrade everyone needs to be using the most recent version, I didn’t want to rely on a pr dance to pin versions, and I also didn’t want to rely on everyone running a command when there’s a change

woodruffw an hour ago | parent | prev [-]

I think you want `uv tool install` and `uv tool upgrade` for that. But also: please file an issue, because it sounds like the kind of papercut we could address somewhat easily!