Live data from Hacker News

Uv's killer feature is making ad-hoc environments easy

valatka.dev

231–240 of 428 posts

Re: Uv's killer feature is making ad-hoc environments easy

#231
post #26

As a NodeJS developer it's still kind of shocking to me that Python still hasn't resolved this mess. Node isn't perfect, and dealing with different versions of Node is annoying, but at least there's none of this "worry about modifying global environment" stuff.

Environment and dependency management in JS-land is even worse. Similar problems with runtime version management (need to use nvm for sanity, using built-in OS package managers seems to consistently result in tears). More package managers and interactions (corepack, npm, pnpm, yarn, bun). Bad package interop (ESM vs CJS vs UMD). More runtimes (Node, Deno, Bun, Edge). Then compound this all with the fact that JS doesn…

Valid criticisms, but the "standard" choices all work well. Nvm is the de facto standard for node version management, npm is a totally satisfactory package manager, node is the standard runtime that those other runtimes try to be compatible with, etc.

Will also note that in my years of js experience I've hardly ever run into module incompatibilities. It's definitely gnarly when it happens, but wouldn't consider this to be the same category of problem as the confusion of setting up python.

Hopefully uv can convince me that python's environment/dependency management can be easier than JavaScript's. Currently they both feel bad in their own way, and I likely prefer js out of familiarity.

Re: Uv's killer feature is making ad-hoc environments easy

#232
post #50

wow, they've re-invented a tiny bit of Nix, purely legend!

That you can use without having 4 PhDs. It's pretty good. You should try it sometime when your done fully ingesting algebraic topology theory or whatever the fuck Nix requires to know just to install figlet.

> You should try it sometime when your done fully ingesting algebraic topology theory or whatever the fuck Nix requires to know

aka how to say that you've never really tried learning Nix without saying it directly.

Re: Uv's killer feature is making ad-hoc environments easy

#234

wow, they've re-invented a tiny bit of Nix, purely legend!

A few months ago I saw someone hacking the linker to get mundane package management working in Nix. It was bubbling up to the top of my "to try" list and that bumped it back down. It'll be good eventually, I'm sure.

> It'll be good eventually, I'm sure.

not with this attitude of getting scared of things by watching someone doing something, for sure

Re: Uv's killer feature is making ad-hoc environments easy

#235

Earlier quoted context omitted.

Nix people are more annoying than Rust Defense Force. I use Windows, and not WSL. Nix does literally nothing for me.

[flagged]

There’s vastly more Windows devs than you realize. Vastly.

Re: Uv's killer feature is making ad-hoc environments easy

#236

Earlier quoted context omitted.

pip's resolving algorithm is not sound. If your Python projects are really simple it seems to work but as your projects get more complex the failure rate creeps up over time. You might pip install something and have it fail and then go back to zero and restart and have it work but at some point that will fail. conda has a correct resolving algorithm but the packages are out of date and add about as many quality probl…

Ugh, I hate writing this but that's where docker and microservices comes to the rescue. It's a pain in the butt and inefficient to run but if you don't care about the overhead (and if you do care, why are you still using Python?), it works.

Docker will make it work, but is a heavy solution as it will happily take up GB of your disk. uv is a more efficient and elegant option.

Re: Uv's killer feature is making ad-hoc environments easy

#237

Earlier quoted context omitted.

I never used anything other than pip. I never felt the need to use anything other than pip (with virtualenv). Am I missing anything?

pip's resolving algorithm is not sound. If your Python projects are really simple it seems to work but as your projects get more complex the failure rate creeps up over time. You might pip install something and have it fail and then go back to zero and restart and have it work but at some point that will fail. conda has a correct resolving algorithm but the packages are out of date and add about as many quality probl…

> You might `pip install` something and have it fail and then go back to zero and restart and have it work but at some point that will fail.

Can you give a concrete example, starting from a fresh venv, that causes a failure that shouldn't happen?

> but it was written in Python and thus had problems with maintaining its own stable Python enivronment

All it has to do is create an environment for itself upon installation which is compatible with its own code, and be written with the capability of installing into other environments (which basically just requires knowing what version of Python it uses and the appropriate paths - the platform and ABI can be assumed to match the tool, because it's running on the same machine).

This is fundamentally what uv is doing, implicitly, by not needing a Python environment to run.

But it's also what the tool I'm developing, Paper, is going to do explicitly.

What's more, you can simulate it just fine with Pip. Of course, that doesn't solve the issues you had with Pip, but it demonstrates that "maintaining its own stable Python environment" is just not a problem.

>Writing uv in Rust was genius because it eliminates that problem of the system having a stable surface to stand on instead of pipping itself into oblivion, never mind that it is much faster than my system would have been.

From what I can tell, the speed mainly comes from algorithmic issues, caching etc. Pip is just slow above and beyond anything Python forces on it.

An example. On my system, creating a new venv from scratch with Pip included (which loads Pip from within its own vendored wheel, which then runs in order to bootstrap itself into the venv) takes just over 3 seconds. Making a new venv without Pip, then asking a separate copy of Pip to install an already downloaded Pip wheel would be about 1.7 seconds. But making that venv and using the actual internal installation logic of Pip (which has been extracted by Pip developer Pradyun Gedam as https://github.com/pypa/installer ) would take about 0.25 seconds. (There's no command-line API for this; in my test environment I just put the `installer` code side by side with a driver script, which is copied from my development work on Paper.) It presumably could be faster still.

I honestly have no idea what Pip is doing the rest of that time. It only needs to unzip an archive and move some files around and perform trivial edits to others.

> (My system had the extra feature that it used http range requests to extract the metadata from wheel files before pypi started letting you download the metadata directly.)

Pip has had this feature for a long time (and it's still there - I think to support legacy projects without wheels, because I think the JSON API won't be able to provide the data since PyPI doesn't build the source packages). It's why the PyPI server supports range requests in the first place.

> I'd worked on plenty of projects where I was right about the technology and wrong about the politics and I am so happy that uv has saved the Python community from itself.

The community's politics are indeed awful. But Rust (or any other language outside of Python) is not needed to solve the problem.

Re: Uv's killer feature is making ad-hoc environments easy

#238

Earlier quoted context omitted.

I don't think so, though maybe I didn't explain myself correctly. You can link to a relative package wheel I think, but not to a package repo. So if you have a repo, with your main package in ./src, and you vendor or need a package from another subfolder (let's say ./vendored/freetype) , you can't actually do it in a way that won't break the moment you share your package. You can't put ./vendored/freetype in your req…

In this scenario, reading between the lines, the vendor is not providing a public / published package but does provide the source as like a tarball? I have yet to run into that particular case where the vendor didn't supply their own repo in favour of just providing the source directly. However I do use what are essentially vendor-supplied packages (distant teams in the org) and in those cases I just point at their G…

It's more for either monorepos or in my case, to fix packages that have bugs but that I can't fix upstream.

So for me, in my specific case, the freetype-py repo has a rather big issue with Unicode paths (it will crash the app if the path is in Unicode).

There's a PR but it hasn't and probably won't get merged for dubious reasons.

The easy choice, the one that actually is the most viable, is to pull the repo with the patch applied, temporarily add it to my ./vendored folder and just ideally change the requirements.txt with no further changes (or need to create a new pypi package). But it's basically impossible since I just can't use relative paths like that.

Again it's rather niche but that's just one of the many problems I keep encountering. packaging anything with CUDA is still far worse, for example.

Re: Uv's killer feature is making ad-hoc environments easy

#239

Earlier quoted context omitted.

Python has been cleaning up a number of really lethal problems like: (i) wrongly configured character encodings (suppose you incorporated somebody else's library that does a "print" and the input data contains some invalid characters that wind up getting printed; that "print" could crash a model trainer script that runs for three days if error handling is set wrong and you couldn't change it when the script was runni…

I don’t exactly remember the situation but a user created a python module named error.py. Then in their main code they imported the said error.py but unfortunately numpy library also has an error.py. So the user was getting very funky behavior.

Yeah, that's not exactly the problematic situation... but the good news is I improved the Python's error message for this in 3.13. See https://docs.python.org/3/whatsnew/3.13.html#improved-error-...

Re: Uv's killer feature is making ad-hoc environments easy

#240
post #163

Earlier quoted context omitted.

> sudo apt-get install python3.10 python3.11 python3.12 This assumes the Python version you need is available from your package manager's repo. This won't work if you want a Python version either newer or older than what is available. > You are incorrect about needing to use an additional tool to install a "global" tool like `ruff`; `pip` does this by default when you're not using a virtual environment. True, but it'…

> pip doesn't resolve dependencies of dependencies. This is simply incorrect. In fact the reason it gets stuck on resolution sometimes is exactly because it resolved transitive dependencies and found that they were mutually incompatible. Here's an example which will also help illustrate the rest of my reply. I make a venv for Python 3.8, and set up a new project with a deliberately poorly-thought-out pyproject.toml:…

> Well, sure; Pip can't respect a version pin that doesn't exist anywhere in your project. If the specific version of Pandas you want says that it's okay with a range of Numpy versions, then of course Pip has freedom to choose one of those versions. If that matters, you explicitly specify it

Nearly every other language solves this better than this. What your suggesting breaks down on large projects.

Post reply on HN