4 ms·
There’s a shebang now. as of PEP 722 you can declare dependencies in a comment at the top of a single file script that a package manager can choose to read and
by easton 2y ago
There’s a shebang now. as of PEP 722 you can declare dependencies in a comment at the top of a single file script that a package manager can choose to read and resolve.
uv has support for it: https://docs.astral.sh/uv/guides/scripts/#running-a-script-with-dependencies https://docs.astral.sh/uv/guides/scripts/#running-a-script-w... (which only helps if your team is all in on uv, but maybe they are)
- eesmith 2y agoPEP 722 was rejected. You are thinking of PEP 723, which was very similar to 722 in goals. https://discuss.python.org/t/pep-722-723-decision/36763 https://discuss.python.org/t/pep-722-723-decision/36763 contains the reasoning for accepting 723 and rejecting 722.
- miohtama 2y agoDo other package managers support this yet?
- zahlman 2y agoPipx isn't in any meaningful sense a package manager (although it can manage environments to a limited extent), but the `pipx run` command supports this PEP as of version 1.4.2.
- amelius 2y agoHow does that work with the shebang?
- oulipo 2y agoCheck eg https://simonwillison.net/2024/Dec/19/one-shot-python-tools/ https://simonwillison.net/2024/Dec/19/one-shot-python-tools/
- wizzard0 2y ago#!uv run # /// script # requires-python = ">=3.10" # dependencies = [ # "click>8", # "rich", # ] # /// and that's it
- amelius 2y agoCool. I wasn't sure it would skip the first comment line.