←back to thread

Fun with uv and PEP 723

(www.cottongeeks.com)
618 points deepakjois | 1 comments | | HN request time: 0.382s | source
Show context
Imustaskforhelp ◴[] No.44376872[source]
I have a lot of opinions about this.

Firstly, I have been a HN viewer for so many time and this is the one thing about pep python scripts THAT always get to the top of leaderboard of hackernews by each person discovering it themselves.

I don't mean to discredit the author. His work was simple and clear to understand. I am just sharing this thesis that I have that if someone wants karma on Hackernews for whatever reason, this might be the best topic. (Please don't pitchfork me since I don't mean offense to the author)

Also, can anybody please explain to me on how to create that pep metadata in uv from just a python script and without anything else, like some command which can take a python script and give pep and add that in the script, I am pretty sure that uv has a feature flag but I feel that the author might've missed out on this feature because I don't know when coding one off scripts in python using AI (gemini) it had some options with pep so I always had to paste uv's documentation I don't know, so please if anybody knows a way to create pep easier using the cli, then please tell me! Thanks in advance!!

replies(1): >>44377087 #
altbdoor ◴[] No.44377087[source]
One can use uv to add into the dependencies list

    $ touch foo.py

    $ uv add --script foo.py requests
    Updated `foo.py`

    $ cat foo.py
    # /// script
    # requires-python = ">=3.13"
    # dependencies = [
    #     "requests",
    # ]
    # ///
replies(1): >>44377443 #
1. Imustaskforhelp ◴[] No.44377443[source]
Thanks a lot friend, But one of the issues with this is that I need to know about requests and sometimes their names can be different and I actually had created a cli tool called uvman which actually wanted to automate that part too.

But my tool was really finnicky and I guess it was built by AI ,so um yea, I guess you all can try it, its on pypi. I think that it has a lot of niche cases where it doesn't work. Maybe someone can modify it to make it better as I had built it like 3-4 months ago if I remember correctly and I have completely forgotten how things worked in uv.