▲ 33 ▼ Lazy self-installing Python scripts with uv (treyhunner.com) submitted 2 years ago by norambna@programming.dev [M] to c/python@programming.dev 8 comments fedilink hide all child comments via https://mastodon.social/@treyhunner/113624679999224789
[–] danielquinn@lemmy.ca 2 points 2 years ago (3 children) This looks like a reimplementation of pipx. permalink fedilink source hideshow 6 child comments replies: [–] Voroxpete@sh.itjust.works 5 points 2 years ago (1 child) Correct me if I'm wrong, but I don't think pipx can allow you to just put a shebang at the top of a script that automatically installs all the required dependencies the first time you run it? What I really like about this, unless I'm missing something, is that it basically lets you create Python scripts that run in exactly the same way as shell scripts. I work with a lot of people who have pretty good basic Linux knowledge, but are completely at a loss when it comes to python specific stuff. Being able to send them a script that they can just +x and run sounds like a huge hassle saver. permalink fedilink source parent hideshow 2 child comments replies: [–] danielquinn@lemmy.ca 1 point 2 years ago (1 child) Nope, pipx definitely can't do that, but the idea that running your yourscript.py --help will automatically trigger the downloading of dependencies and installing them somewhere isn't really appealing. I'm sure I'm not the only person who's got uv configured to install the virtualenv in the local .venv folder rather than buried into my home dir, so this would come with the added surprise that every time I invoke the script, I'd get a new set of dependencies installed wherever I happen to be. I mean, it's neat that you can do this, but as a user I wouldn't appreciate the surprise behaviour. pipx isn't perfect, but at least it lets you manage things like updates. permalink fedilink source parent hideshow 2 child comments replies: [–] eager_eagle@lemmy.world 1 point 2 years ago* I’m sure I’m not the only person who’s got uv configured to install the virtualenv in the local .venv folder That's the default for projects. Script is a different run mode. every time I invoke the script, I’d get a new set of dependencies installed wherever I happen to be. Does that happen though? uv uses the cache location for these script dependencies, not your usual venv one. Where you call it from is not a factor. permalink fedilink source parent [–] cd_slash_rmrf@programming.dev 5 points 2 years ago uv actually does have a reimplementation of pipx, via uv tool or uvx: https://docs.astral.sh/uv/concepts/tools/#tools the concept in the OP is different; it's an implementation of pep722 https://peps.python.org/pep-0722/ permalink fedilink source parent [+] eager_eagle@lemmy.world 1 point 2 years ago [deleted] permalink fedilink source parent
[–] Voroxpete@sh.itjust.works 5 points 2 years ago (1 child) Correct me if I'm wrong, but I don't think pipx can allow you to just put a shebang at the top of a script that automatically installs all the required dependencies the first time you run it? What I really like about this, unless I'm missing something, is that it basically lets you create Python scripts that run in exactly the same way as shell scripts. I work with a lot of people who have pretty good basic Linux knowledge, but are completely at a loss when it comes to python specific stuff. Being able to send them a script that they can just +x and run sounds like a huge hassle saver. permalink fedilink source parent hideshow 2 child comments replies: [–] danielquinn@lemmy.ca 1 point 2 years ago (1 child) Nope, pipx definitely can't do that, but the idea that running your yourscript.py --help will automatically trigger the downloading of dependencies and installing them somewhere isn't really appealing. I'm sure I'm not the only person who's got uv configured to install the virtualenv in the local .venv folder rather than buried into my home dir, so this would come with the added surprise that every time I invoke the script, I'd get a new set of dependencies installed wherever I happen to be. I mean, it's neat that you can do this, but as a user I wouldn't appreciate the surprise behaviour. pipx isn't perfect, but at least it lets you manage things like updates. permalink fedilink source parent hideshow 2 child comments replies: [–] eager_eagle@lemmy.world 1 point 2 years ago* I’m sure I’m not the only person who’s got uv configured to install the virtualenv in the local .venv folder That's the default for projects. Script is a different run mode. every time I invoke the script, I’d get a new set of dependencies installed wherever I happen to be. Does that happen though? uv uses the cache location for these script dependencies, not your usual venv one. Where you call it from is not a factor. permalink fedilink source parent
[–] danielquinn@lemmy.ca 1 point 2 years ago (1 child) Nope, pipx definitely can't do that, but the idea that running your yourscript.py --help will automatically trigger the downloading of dependencies and installing them somewhere isn't really appealing. I'm sure I'm not the only person who's got uv configured to install the virtualenv in the local .venv folder rather than buried into my home dir, so this would come with the added surprise that every time I invoke the script, I'd get a new set of dependencies installed wherever I happen to be. I mean, it's neat that you can do this, but as a user I wouldn't appreciate the surprise behaviour. pipx isn't perfect, but at least it lets you manage things like updates. permalink fedilink source parent hideshow 2 child comments replies: [–] eager_eagle@lemmy.world 1 point 2 years ago* I’m sure I’m not the only person who’s got uv configured to install the virtualenv in the local .venv folder That's the default for projects. Script is a different run mode. every time I invoke the script, I’d get a new set of dependencies installed wherever I happen to be. Does that happen though? uv uses the cache location for these script dependencies, not your usual venv one. Where you call it from is not a factor. permalink fedilink source parent
[–] eager_eagle@lemmy.world 1 point 2 years ago* I’m sure I’m not the only person who’s got uv configured to install the virtualenv in the local .venv folder That's the default for projects. Script is a different run mode. every time I invoke the script, I’d get a new set of dependencies installed wherever I happen to be. Does that happen though? uv uses the cache location for these script dependencies, not your usual venv one. Where you call it from is not a factor. permalink fedilink source parent
[–] cd_slash_rmrf@programming.dev 5 points 2 years ago uv actually does have a reimplementation of pipx, via uv tool or uvx: https://docs.astral.sh/uv/concepts/tools/#tools the concept in the OP is different; it's an implementation of pep722 https://peps.python.org/pep-0722/ permalink fedilink source parent