`uv` remains very cool
ertius passim, I mentioned how nice uv was
for running other people's code. It's also great for running your
own, without having to even explicitly make a virtualenv:
$ uv run --with ruamel.yaml cross_check_dns.py
More recently (edit: not true! This is from PEP
723 from almost two years ago!),
uv got the ability to magically embed that in the shebang and do:
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "ruamel.yaml",
# "asyncssh"
# ]
# ///
The shebang - /usr/bin/env -S uv run --script - is maybe not what
you'd expect, e.g. /usr/bin/env uv run --with somedep etc, because
shebang parsing is basically very fucking weird. See
this for enormous
amounts of detail, but in short, shebangs were introduced to Unix in
~1980 and didn't have "just split all the other args on space like a
shell" behaviour, and everyone has cloned that ever since.
Fortunately, FreeBSD improved the state of the
art
by adding -S to env in FreeBSD
6.0 in
2008, and then coreutils added it for Linux in
8.3.0 in
2018 (can't rush these things).
In the past there was always some friction for me when deciding to
start using something outside the stdlib - at that point I have to
stop just python blah.py and worry about a setup.py and creating a
virtualenv to install deps in, and further back, worry a lot about how
easily buildable my deps would be. Now it's all incredibly easy, and
in practice rather like the pleasant mostly-static-linking that Go and
Rust have by default.
sources: