Live data from Hacker News

Uv: Running a script with dependencies

docs.astral.sh

21–30 of 174 posts

Re: Uv: Running a script with dependencies

#21
post #17
post #15

Earlier quoted context omitted.

https://en.wikipedia.org/wiki/Shebang_(Unix)#Argument_splitt...

Thanks, but the main question is how come the behaviour is still the same whether you pass the flag or not? I would get it if it just failed without "-S" but it works as intended. I am wondering if this is cause I might not be using the GNU version of env, so this is less relevant? Edit: looks to be the version thing indeed, this doesn't work for someone on Ubuntu

At some point coreutils added -S in order to support the behavior of BSD and MacOS. I would guess that whatever implementation you're using then added -S as a noop in order to (at long last) permit the portable usage of multi-argument shebang lines. Until both of those things happened there was no portable way to pass multiple arguments in a shebang. You used to have to do really stupid things (ex https://unix.stackexchange.com/a/399698).

https://www.gnu.org/software/coreutils/manual/html_node/env-...

Re: Uv: Running a script with dependencies

#22

Earlier quoted context omitted.

I thought that was a heart emoticon next to requests, for a second.

I mean, who doesn't love requests?

Well... maybe the people who have stopped working on it due to the mysterious disappearance of 30,000 fundraised dollars, selling paid support but "delegat[ing] the actual work to unpaid volunteers", and a pattern of other issues from other community members who have not spoken up about them.

https://vorpus.org/blog/why-im-not-collaborating-with-kennet...

https://news.ycombinator.com/item?id=19826680

Re: Uv: Running a script with dependencies

#24
post #4

The "declaring script dependencies" thing is incredibly useful: https://docs.astral.sh/uv/guides/scripts/#declaring-script-d... # /// script # dependencies = [ # "requests Save that as script.py and you can use "uv run script.py" to run it with the specified dependencies, magically installed into a temporary virtual environment without you having to think about them at all. It's an implementation of Python PEP 723: h…

shebang mode is also incredibly useful and allows execution like ./script.sh

  #!/usr/bin/env -S uv run --script
  # /// script
  # dependencies = [
  #   "requests

Re: Uv: Running a script with dependencies

#25
I hate such poor docs that don't explain how things work, and instead prefer hiding behind some "magic".

> Constraints can be added to the requested dependency if specific versions are needed:

> uv run --with 'rich>12,Why not mention that this will make uv download specified versions of specified packages somewhere on the disk. Where? Are those packages going to get cached somewhere? Or will it re-download those same packages again and again every time you run this command?

Re: Uv: Running a script with dependencies

#26

I hate such poor docs that don't explain how things work, and instead prefer hiding behind some "magic". > Constraints can be added to the requested dependency if specific versions are needed: > uv run --with 'rich>12, Why not mention that this will make uv download specified versions of specified packages somewhere on the disk. Where? Are those packages going to get cached somewhere? Or will it re-download those sam…

I mean... it's in the docs?

https://docs.astral.sh/uv/concepts/cache/

Re: Uv: Running a script with dependencies

#29

I hate such poor docs that don't explain how things work, and instead prefer hiding behind some "magic". > Constraints can be added to the requested dependency if specific versions are needed: > uv run --with 'rich>12, Why not mention that this will make uv download specified versions of specified packages somewhere on the disk. Where? Are those packages going to get cached somewhere? Or will it re-download those sam…

Caching linked on the left: https://docs.astral.sh/uv/concepts/cache/ The index of the Concepts section says: "Looking for a quick introduction to features? See the guides instead."

Maybe there should instead be a link to the Concepts section for people who want more details, but I feel it's fine as it is.

Post reply on HN