Live data from Hacker News

Self-contained Python scripts with uv

blog.dusktreader.dev

1–10 of 114 posts

Re: Self-contained Python scripts with uv

#4
post #3

Has anyone gotten this to work on Windows? I wanted to use this trick for some tooling for a game mod I'm working on but couldn't get the shebang trick to work.

I haven't done dev on windows in many years, but IIRC windows doesn't have shebang support.

Re: Self-contained Python scripts with uv

#7
post #3

Has anyone gotten this to work on Windows? I wanted to use this trick for some tooling for a game mod I'm working on but couldn't get the shebang trick to work.

I haven't done dev on windows in many years, but IIRC windows doesn't have shebang support.

But it does support registering extension handlers[1], so if you name your scripts with say .pyuv and register "uv run --script %1", or whatever it would take to run uv, as the handler of .pyuv files, it should work. Unless uv does something funky that is.

You could do this during an installation step, for example.

[1]: https://learn.microsoft.com/en-us/windows/win32/shell/fa-fil...

Re: Self-contained Python scripts with uv

#8
This looks quite useful! Is uv a safer choice to use for deploying a python based project long term? I’m referring to the anaconda rug pull that happened- using it for managing dependencies about 5 years ago, but then they changed some rules so that any of my clients who are organizations with over 200 employees are no longer free to use anaconda. They must pay a commercial license

Re: Self-contained Python scripts with uv

#9
post #3

Has anyone gotten this to work on Windows? I wanted to use this trick for some tooling for a game mod I'm working on but couldn't get the shebang trick to work.

I use this frequently on Windows and Linux. These are the steps I take:

$> uv init --script .py

$> uv add --script .py ...

$> uv add --script .py --dev ...

$> uv run .py

Hope this helps :)

Source: https://docs.astral.sh/uv/guides/scripts/

Re: Self-contained Python scripts with uv

#10
post #8

This looks quite useful! Is uv a safer choice to use for deploying a python based project long term? I’m referring to the anaconda rug pull that happened- using it for managing dependencies about 5 years ago, but then they changed some rules so that any of my clients who are organizations with over 200 employees are no longer free to use anaconda. They must pay a commercial license

As I understand it, relicensing is possible when a project has a Contributor Licensing Agreement (CLA) which says that you're signing over your copyright to your contribution to the project's owners. (Who will eventually be bought out by the worst rich person you can think of - Yes, him.)

I peeked in uv's contributing guide and issues and didn't see any CLA. In PyTorch the CLA was mentioned at the top of the contributing guide.

Although, there should have been a community fork of the last FOSS version of Anaconda. That's what happened with Redis, and Redis uses a CLA: https://github.com/redis/redis/blob/unstable/CONTRIBUTING.md...

Don't ever sign a CLA, kids. Hell, only contribute to copyleft projects. We get paid too much to work for free.

Post reply on HN