←back to thread

/usr/bin/env -S uv run

(simonwillison.net)
125 points jcbhmr | 2 comments | | HN request time: 0.402s | source
Show context
mrweasel ◴[] No.42202316[source]
While neat, doesn't it also comes with certain issues?

Startup times has to be slower, but probably only for the first run?

There's a some level of violation of the "Principle Of Least Surprise", depending on the setting. For some it will be the reverse, the script they got just works, without any setup or package installation. For others we'll wonder why it just started downloading a bunch of packages we already have.

Probably not the greatest idea for production environments, where you should not or can not just pull in packages from the internet.

It's really cool that it works, but I think I'd recommended using it highly selectively.

replies(3): >>42202633 #>>42202803 #>>42202806 #
BiteCode_dev ◴[] No.42202806[source]
Definitely not for prod, but I used to have (and recommend: https://www.bitecode.dev/i/114175324/whats-a-good-name-for-a...) a giant venv just for my laptop scripts. Having one per script is too much, but none is inviting pain.

The problem with that is that eventually too many scripts means you will hit incompatibilities in Python where you can only install one version of a lib in each venv.

This trick is perfect because:

- From now on, I always install uv on all my machines anyway.

- After the first run, not only the cache make it fast, but it uses hard links so that you don't even pay the of multiple install on disk space (that's also how they are so fast in creating the envs, that and some interesting HTTP/zip tricks: https://www.bitecode.dev/p/charlie-marsh-on-astral-uv-and-th...).

- Deps are clearly defined in the script, so it's self-documenting.

For prod, shiv (https://shiv.readthedocs.io/) is probably your best bet but I'm betting uv will come up with a version of that soon.

replies(1): >>42203804 #
quickslowdown ◴[] No.42203804[source]
I want to understand shiv, but I just can't grok it. I've successfully made a PyInstaller executable in the past.

Do you have any good sources for learning shiv? The docs are very sparse & lack examples and there aren't as many blogs discussing shiv as I'd hoped.

Also, do you know if shiv works on Windows?

replies(1): >>42204082 #
1. BiteCode_dev ◴[] No.42204082[source]
Unfortunatly no, plus the docs are indeed not great and the UI itself is lacking.

But yes, unlike pex, shiv works on windows.

It's very different than pyinstaller in the sense that:

- it uses a standard (the zipapp format from python stdlib)

- it assumes python is already installed (it's not stand alone)

I definitely should write on article on that on Bite Code on day. Adding it to the list.

replies(1): >>42217934 #
2. quickslowdown ◴[] No.42217934[source]
I'd read it! :) I want to understand Shiv, but I haven't even gotten it to work after a few hours tinkering, and that's usually where I give up and look to another tool.