Live data from Hacker News

Uv is the best thing to happen to the Python ecosystem in a decade

emily.space

291–300 of 1001 posts

Re: Uv is the best thing to happen to the Python ecosystem in a decade

#291
post #263
post #239

Earlier quoted context omitted.

I have used pip freeze > requirements.txt pip install -r requirements.txt Way before "official" lockfile existed. Your requirements.txt becomes a lockfile, as long as you accept to not use ranges. Having this in a single tool etc why not, but I don't understand this hype, when it was basically already there.

Good luck if you need cross-platform `requirements.txt` files.

This is a good use case. Not sure how this is typically solved, I guess "requirements-os-version.txt"? A bit redundant and repetitive.

I would probably use something like this: https://stackoverflow.com/questions/17803829/how-to-customiz...

Re: Uv is the best thing to happen to the Python ecosystem in a decade

#292

I gotta say, I feel pretty vindicated after hearing for years how Python’s tooling was just fine and you should just use virtualenv with pip and how JS must be worse, that when Python devs finally get a taste of npm/cargo/bundler in their ecosystem, they freaking love it. Because yes, npm has its issues but lock files and consistent installs are amazing

There is nothing I dread more within the general context of software development, broadly , than trying to run other people's Python projects. Nothing. It's shocking that it has been so bad for so long.

You aren’t kidding. Especially if it’s some bioinformatics software that is just hanging out there on GitHub older than a year…

Re: Uv is the best thing to happen to the Python ecosystem in a decade

#293

God yes. I got dragged into the uv when I started using copyparty and I am a fanatical admirer ever since. I also use pipx to install tools often. I really don't understand why you can't just pip install something globally. I want this package to be available to me EVERYWHERE, why can't I do it? I only use python recreationally because everyone uses python everywhere and you can't escape it. So there is a massive pos…

> I want this package to be available to me EVERYWHERE, why can't I do it?

Because it being available in the system environment could cause problems for system tools, which are expecting to find something else with the same name.

And because those tools could include your system's package manager (like Apt).

> So there is a massive possibility I am simply wrong and pip-installing something globally is a huge risk. I'm just not understanding it.

I assume you're referring to the new protections created by the EXTERNALLY-MANAGED marker file, which will throw up a large boilerplate warning if you try to use pip to install packages in the system environment (even with --user, where they can still cause problems when you run the system tools without sudo).

You should read one or more of:

* the PEP where this protection was introduced (https://peps.python.org/pep-0668/);

* the Python forum discussion explaining the need for the PEP (https://discuss.python.org/t/_/10302);

* my blog post (https://zahlman.github.io/posts/2024/12/24/python-packaging-...) where I describe in a bit more detail (along with explaining a few other common grumblings about how Python packaging works);

* my Q&A on Codidact (https://software.codidact.com/posts/291839/) where I explain more comprehensively;

* the original motivating Stack Overflow Q&A (https://stackoverflow.com/questions/75608323/);

* the Python forum discussion (https://discuss.python.org/t/_/56900) where it was originally noticed that the Stack Overflow Q&A was advising people to circumvent the protection without understanding it, and a coordinated attempt was made to remedy that problem.

Or you can watch Brodie Robertson's video about the implementation of the PEP in Arch: https://www.youtube.com/watch?v=35PQrzG0rG4.

Re: Uv is the best thing to happen to the Python ecosystem in a decade

#294
post #193

Earlier quoted context omitted.

poetry gave us lock files and consistent installs for years. uv is much, much faster however.

I used poetry professionally for a couple of years and hit so many bugs, it was definitely not a smooth experience. Granted that was probably 3-4 years ago.

I started using poetry abiut 4 years ago and definitely hit a lot of bugs around that time, but it seems to have improved considerably. That said, my company has largely moved to uv as it does seem easier to use (particularly for devs coming from other languages).

Re: Uv is the best thing to happen to the Python ecosystem in a decade

#295
post #290
post #239

Earlier quoted context omitted.

I have used pip freeze > requirements.txt pip install -r requirements.txt Way before "official" lockfile existed. Your requirements.txt becomes a lockfile, as long as you accept to not use ranges. Having this in a single tool etc why not, but I don't understand this hype, when it was basically already there.

It is also manages the runtime, so you can pin a specific runtime to a project. It is very useful and worth investigating.

I think it's a great modern tool, don't get me wrong.

But the main reason shouldn't be the "lockfile". I was replying to the parent comment mainly for that particular thing.

Re: Uv is the best thing to happen to the Python ecosystem in a decade

#296
post #239

Earlier quoted context omitted.

I have used pip freeze > requirements.txt pip install -r requirements.txt Way before "official" lockfile existed. Your requirements.txt becomes a lockfile, as long as you accept to not use ranges. Having this in a single tool etc why not, but I don't understand this hype, when it was basically already there.

That works for simple cases. Now, update a transitive dependency used by more than one dependency. You might get lucky and it'll just work.

I remember advocating for running nightly tests on every project/service I worked on because inevitably one night one of the transitive dependencies would update and shit would break. And at least with the nightly test it forced it to break early vs when you needed to do something else like an emergency bug fix and ran into then..

Re: Uv is the best thing to happen to the Python ecosystem in a decade

#297
post #69

Am I the only one who feels like this is obviated by Docker? uv is a clear improvement over pip and venv, for sure. But I do everything in dev containers these days. Very few things get to install on my laptop itself outside a container. I've gotten so used to this that tools that uninstall/install packages on my box on the fly give me the heebie-jeebies.

> Am I the only one who feels like this is obviated by Docker?

This whole discussion has the same vibes like digital photography 15 years ago. Back then some people spent more time on discussing the tech spec their cameras than takin photos. Now some people spend more time on discussing the pros and cons of different Python environment management solutions than building real things.

The last time I had to touch one of my dockerized environments was when Miniconda and Miniforge were merged. I said the agent "fix the dockerfile", and the third attempt worked. Another time, one dependency was updated and I had to switch to Poetry. Once again, I said the agent "refactor the repository to Poetry" and it worked. Maybe because all my Python package versions are frozen and I only update them when they break or when I need the functionality of the new version.

Whenever this topic pops up in real life, I always ask back what was the longest time they managed the same Python service in the cloud. In the most cases, the answer is never. The last time someone said one year. After a while this service was turned into two .py files.

I don't know. Maybe I'm just too far away from FAANG level sorcery. Everything is a hammer if all you have to deal with are nails.

Re: Uv is the best thing to happen to the Python ecosystem in a decade

#298
post #239

Earlier quoted context omitted.

I have used pip freeze > requirements.txt pip install -r requirements.txt Way before "official" lockfile existed. Your requirements.txt becomes a lockfile, as long as you accept to not use ranges. Having this in a single tool etc why not, but I don't understand this hype, when it was basically already there.

That works for simple cases. Now, update a transitive dependency used by more than one dependency. You might get lucky and it'll just work.

Can you elaborate on this? How is npm/cargo/etc better than pip on this regard?

As far as I know, files like requirements.txt, package.json, cargo.toml are intended to be used as a snapshot of the dependencies in your project.

In case you need to update dependency A that also affects dependency B and C, I am not sure how one tool is better than other.

Re: Uv is the best thing to happen to the Python ecosystem in a decade

#299
post #173

Earlier quoted context omitted.

There are basically 0 other programming languages that use the "directory/shell integration activated virtual environment", outside of Python. How does the rest of the world manage to survive without venvs? Config files in the directory. Shocking, really :-)))

what happens when you have two projects using different versions of node, etc? isn't that a massive headache? not that it's great to start with, but it does happen, no?

The rest of the world handles that through PATH/PATH equivalent.

Either the package manager is invoked with a different PATH (one that contains the desired Node/Java/whatever version as a higher priority item than any other version on the system).

Or the package manager itself has some way to figure that out through its config file.

Or there is a package manager launch tool, just like pyenv or whatever, which does that for you.

In practice it's not that a big of a deal, even for Maven, a tool created 21 years ago. As the average software dev you figure that stuff out a few weeks into using the tool, maybe you get burnt a few times early on for misconfiguring it and then you're on autopilot for the rest of your career.

Wait till you hear about Java's CLASSPATH and the idea of having a SINGLE, UNIFIED package dependency repo on your system, with no need for per-project dependency repos (node_modules), symlinks, or all of that stupidity.

CLASSPATH was introduced by Java in 1996, I think, and popularized for Java dependency management in 2004.

Re: Uv is the best thing to happen to the Python ecosystem in a decade

#300
post #193

Earlier quoted context omitted.

poetry gave us lock files and consistent installs for years. uv is much, much faster however.

I used poetry professionally for a couple of years and hit so many bugs, it was definitely not a smooth experience. Granted that was probably 3-4 years ago.

I always loved poetry but then I’d always run into that bug where you can’t use repos with authentication. So I’d always go somewhere else eventually.

Some time ago I found out it does work with authentication, but their “counter ascii animation” just covers it… bug has been open for years now…

Post reply on HN