Live data from Hacker News

Uv: Running a script with dependencies

docs.astral.sh

161–170 of 174 posts

Re: Uv: Running a script with dependencies

#161
post #60

Earlier quoted context omitted.

I had the same sentiment, but uv seems to have eliminated the competition. Installing uv using your OS package manager is enough as it can also download and install (isolated) Python interpreters as well.

Except pip still exists and is default, and even if they adopted uv as default instead, all the legacy stuff takes years to change.

> even if they adopted uv as default instead, all the legacy stuff takes years to change

Who are "they"? I am not waiting for anyone to adopt uv. I've adopted it myself and forgotten about pip as uv is pip-compatible for all practical purposes.

Re: Uv: Running a script with dependencies

#162

Earlier quoted context omitted.

Except pip still exists and is default, and even if they adopted uv as default instead, all the legacy stuff takes years to change.

> even if they adopted uv as default instead, all the legacy stuff takes years to change Who are "they"? I am not waiting for anyone to adopt uv. I've adopted it myself and forgotten about pip as uv is pip-compatible for all practical purposes.

The Python foundation first off, then companies and teams using it. If you're a 1-person team then sure you pick everything, but even then you have to worry about compatibility with other tools. Like, Heroku only got support recently: https://www.heroku.com/blog/local-speed-smooth-deploys-herok... or if you're running someone else's code, maybe you have to figure out your own pyproject.toml

Compare to npm which has been the default installer/manager in NodeJS since forever, so it's totally supported, and any git repo you happen to download has a package.json

Re: Uv: Running a script with dependencies

#163
post #86
post #36

Earlier quoted context omitted.

Kenneth Reitz has been good and bad at times. And while things of his are genius level, he also has done asshole level things. But on the other hand, we get that with a lot of geniuses for some reason or another. Really smart people can be really dumb too. It would be like saying, "Don't use Laplace transforms because he did some unsavory thing at some point in time."

Looking at this drama for a bit, I haven't seen anybody advocate for 'canceling' requests itself. Maybe it's more like: Laplace created awesome things, but let's be fair and also put in his wikipedia page a bit about his political shenanigans. A lot of of so-called geniuses, especially the self-styled ones with some narcissistic traits, get away with being an asshole. Their admirers have different norms for regular,…

It wasn't really requests that got cancelled, it was pipenv that got cancelled, about the time when Jacob Kaplan-Moss stated that poetry was good. And frankly it was Reitz's actions that directly caused pipenv to be cancelled.

I'm not defending his assholery here, but it's not uncommon in tech.

Take an asshole techie and notice they tend to have devoted fans. It's just possible that Kenneth Reitz didn't get his fan base up before he exposed his personality for who he truly was. Steve Jobs, Zuck, Bill Gates, Linus Torvalds, ... were all called assholes at some point or another. Geez and those people aren't even the worst these days.

Re: Uv: Running a script with dependencies

#164
post #35

Earlier quoted context omitted.

I've played with it for a while now, and for one off scripts where python might make more sense than bash, e.g., I write the script this way with uv, and then I only need uv and the script. One of the complaints about python is that a script stops working over time (because the python installation changes with os updates), and this kinda sorta doesn't make it go away entirely, but what it does do is to eliminate a bu…

> this kinda sorta doesn't make it go away entirely it absolutely can, `uv` can also pin the python interpreter it uses with `requires-python = "==3.11"` or whatever.

No, because with golang you can drop the binary in an empty docker container and you're done -- you never have to recompile it or worry about your pypi mirror disappearing. If you're deploying a python script with uv, it needs some kind of internet connection.

Jar files are closer maybe...

Re: Uv: Running a script with dependencies

#165

Earlier quoted context omitted.

Beyond that, the needed name to download from PyPI doesn't necessarily have anything at all to do with the name used for an `import` statement. And a given PyPI download may satisfy multiple `import` statements. And it can even be possible to require a download from PyPI that doesn't install any importable code (it may legally be a meta-package that runs one-shot configuration code when "built from source").

> Beyond that, the needed name to download from PyPI doesn't necessarily have anything at all to do with the name used for an `import` statement. And a given PyPI download may satisfy multiple `import` statements. I think this is a design issue with PyPI though. It really should have some kind of index which goes from module names to packages which provide that module. (Maybe it already does but I don't know about it…

> I think this is a design issue with PyPI though. It really should have some kind of index which goes from module names to packages which provide that module. (Maybe it already does but I don't know about it?)

PyPI never really saw much "design" (although there is a GitHub project for the site: https://github.com/pypi/warehouse/ as well as for a mirror client: https://github.com/pypa/bandersnatch). But an established principle now is that anyone can upload a distribution with whatever name they want — first come, first serve by default. Further, nobody has to worry about what anyone else's existing software is in order to do this. Although there are restrictions to avoid typo-squatting or other social engineering attempts (and in the modern era, names of standard library modules are automatically blacklisted).

> Of course, that doesn't help if multiple packages provide the same module; but then if there was a process to reserve a module name – either one which no package is currently using, or if it is currently used only by a single package, give the owner of that package ownership of the module – and then the module name owner can bless a single package as the primary package for that module name.

These kinds of conflicts are actually by design. You're supposed to be able to have competing implementations of the same API.

> Obviously it shouldn't do this by default... maybe something like "from __future__ import auto_install" to enable it.

The language is not realistically going to change purely to support packaging. The time to propose this was in 2006. (Did you know pip was first released before Python 3.0?)

> but maybe Python will eventually get there.

That would require the relevant people to agree that with heading in that direction. IMX, they have many reasons they don't want to.

Anyway, this isn't the place to pitch such ideas. It would be better to try the Ideas and/or Packaging forums on https://discuss.python.org — but be prepared for them to tell you the same things.

Re: Uv: Running a script with dependencies

#166
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…

> without you having to think about them at all. Hahahahaha. Oh. I'm rolling on the floor. Hahahahaha. How do you never learn? No, honestly, how do you never learn this simple thing: it will break! I will bet my pension on that it will break, and perhaps not you, but some hundreds of developers will have to try to debug and try to figure out where the dependencies went and why they weren't installed correctly, or why…

Have you used uv run?

Re: Uv: Running a script with dependencies

#168
post #166

Earlier quoted context omitted.

> without you having to think about them at all. Hahahahaha. Oh. I'm rolling on the floor. Hahahahaha. How do you never learn? No, honestly, how do you never learn this simple thing: it will break! I will bet my pension on that it will break, and perhaps not you, but some hundreds of developers will have to try to debug and try to figure out where the dependencies went and why they weren't installed correctly, or why…

Have you used uv run?

Out of curiosity, yes, I did. But I don't have any use for this tool. I can do better without it. I use these tools because I'm often requested to help those who use them and in so doing make a mess out of their working environment to the point that they can no longer do any work. So, I want to be up to date on latest threats. But as for my personal work with Python, there's simply no use-case where I'd need a tool like uv. It serves no purpose.

Re: Uv: Running a script with dependencies

#169
post #166

Earlier quoted context omitted.

Have you used uv run?

Out of curiosity, yes, I did. But I don't have any use for this tool. I can do better without it. I use these tools because I'm often requested to help those who use them and in so doing make a mess out of their working environment to the point that they can no longer do any work. So, I want to be up to date on latest threats. But as for my personal work with Python, there's simply no use-case where I'd need a tool l…

A lot of people disagree with you there.

I've found it extremely useful because it makes it trivial for me to try out new dependency versions without thinking about which environment should install them in first.

When I'm teaching people Python the earliest sticking point is always "now activate your virtual environment" - being able to avoid that is huge.

Post reply on HN