Comment by BiteCode_dev
14 days ago
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.
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?
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.
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.