Hacker News new | ask | show | jobs
by dietr1ch 166 days ago
Yeah, but you need `uv`. If we are reaching out for tools that might not be around, then you can also depend on nix-shell,

    #! /usr/bin/env nix-shell
    #! nix-shell -i python3 --packages python3
4 comments

Yeah, but you need Nix. If we are reaching out for tools that might not be around, then you can also depend on `curl | sudo bash` to install Nix when not present.

(this is a joke btw)

Yeah, but you need curl, sudo, and bash…
"Give me a 190-byte hex0 seed of x86 assembly, and I shall compile the rest of the world." - Archimedes
amazing quote. Adding it to my about page, do you want credit or shall I credit it to archimedes xD

On a serious note, its so brilliant that something like this is now possible when we think about it. It's maddeningly crazy to think about all the process but in the end that you can end up with a system / linux iso whose hash you can trust/independently verify and then you use it and spread around the world. Definitely makes me feel as sky's the only limit or just its very pleasant to think about it.

... you must first invent the universe
As shared in a sibling comment, you can get away with just curl+shell: https://paulw.tokyo/standalone-python-script-with-uv/
The issue I have with `nix-shell` is that the evaluation time is long, so if you need to run the script repeatedly it may take a long time. `nix shell` at least fix this issue by caching evaluations, but I think uv is still faster.
This comes with the added benefit that your environment is reverted as soon as you exit the Nix shell.
I dont think your emvironment is permanently changed with uv run?
Where does uv download the Python interpreter to?
By default, it's `~/Library/Caches/uv/environments-v2/` on macos.

Can find via `uv cache dir`

See: https://docs.astral.sh/uv/reference/cli/#uv-cache-dir