Most active commenters
  • petersellers(3)
  • rednafi(3)

←back to thread

Fun with uv and PEP 723

(www.cottongeeks.com)
618 points deepakjois | 22 comments | | HN request time: 1.394s | source | bottom
1. 4dregress ◴[] No.44374002[source]
I’ve been a python dev for nearly a decade and never once thought dep management was a problem.

If I’ve ever had to run a “script” in any type of deployed ENV it’s always been done in that ENVs python shell .

So I still don’t see what the fuss is about?

I work on a massive python code base and the only benefit I’ve seen from moving to UV is it has sped up dep installation which has had positive impact on local and CI setup times.

replies(7): >>44374205 #>>44374268 #>>44374280 #>>44374598 #>>44375288 #>>44378102 #>>44391546 #
2. petersellers ◴[] No.44374205[source]
> it’s always been done in that ENVs python shell .

What if you don't have an environment set up? I'm admittedly not a python expert by any means but that's always been a pain point for me. uvx makes that so much easier.

replies(2): >>44374524 #>>44378236 #
3. jshen ◴[] No.44374268[source]
Python's dependency management has been terrible until very recently compared to nearly every other mainstream language.
4. bboygravity ◴[] No.44374280[source]
How did you tell other people/noobs to run your python code (or how did you run it yourself after 5+ years of not touching older projects)?
replies(1): >>44376067 #
5. kinow ◴[] No.44374524[source]
I wrote PHP/JS/Java before Python. Been doing Python for nearly a decade too, and like 4dregress haven't had the need to worry much about dep management. JS and PHP had all sorts of issues, Maven & Gradle are still the ones that gave me less trouble. With Python I found that most issues could be fixed by finding the PEP that implemented what I needed, and by trying to come up with a simple workflow & packaging strategy.

Nowadays I normally use `python venv/bin/<some-executable>`, or `conda run -n <some-env> <some-executable>`, or packaged it in a Singularity container. And even though I hear a lot of good things about uv, given that my job uses public money for research, we try to use open source and standards as much as possible. My understanding is that uv is still backed by a company, and at least when I checked it some time ago (in peps discussions & GH issues) they were no implementing the PEPs that I needed -- even if they did, we would probably still stay with simple pip/setuptools to avoid having to use research budget to update our build if the company ever changed its business model (e.g. what anaconda did some months/year? ago).

Digressing: the Singularity container is useful for research & HPC too, as it creates a single archive, which is faster to load on distributed filesystems like the two I work on (GPFS & LustreFS) instead of loading many small files over network.

6. rednafi ◴[] No.44374598[source]
I guess this is why people need to get out of this “Python dev” or “JS dev” mindset and try other languages to see why those coming to Python complain so much about dependency management.

People complain because the experience is less confusing in many other languages. Think Go, Rust, or even JS. All the tooling chaos and virtual environment jujitsu are real deterrents for newcomers. And it’s not just beginners complaining about Python tooling. Industry veterans like Armin Ronacher do that all the time.

uv is a great step in the right direction, but the issue is that as long as the basic tooling isn’t built into the language binary, like Go’s tools or Rust’s Cargo, more tools will pop up and fragment the space even further.

replies(2): >>44375279 #>>44375617 #
7. mmcnl ◴[] No.44375279[source]
Confusing is underselling it. That implies that Python dependency management is working fine, it's just complex. But it's not working fine: there's no such thing as lock files, which makes reproducible installs a gamble and not a given. For small scripts this is probably "okay", but if you're working in a team or want to deploy something on a server, then it's absolutely not fine because you want deterministic builds and that's simply impossible without a decent package manager.

Tools like uv solve the "it works on my machine" problem. And it's also incredibly fast.

replies(1): >>44375387 #
8. mmcnl ◴[] No.44375288[source]
Virtual environments alone are not enough. They don't guarantee deterministic builds. What do you do to ensure that your production environment runs the same code as your local dev environment? How do you solve that problem without dependency managers like uv or poetry?
9. rednafi ◴[] No.44375387{3}[source]
There is a lock file now.

https://packaging.python.org/en/latest/specifications/pylock...

Issue is since there are no standardized build tool (pip, uv both are third party), there are a zillion ways of generating this lockfile unlike go.mod or cargo.toml. So it doesn't work in many scenarios and it's confusing as hell.

10. 4dregress ◴[] No.44375617[source]
My view is I’m an engineer first and foremost and I use the tools which are best for the task at hand. That also means what’s best for the business in terms of others working on the project, this has meant python with some sort of framework.

People have suggested using other languages that might be faster but the business always choices what’s best for everyone to work with.

replies(1): >>44375800 #
11. rednafi ◴[] No.44375800{3}[source]
Sure, it depends on the type and maturity of the business, as well as the availability of local talent. I've worked at three companies that started out with Python and Django, then transitioned to other technologies as the business scaled. In those environments, there were two kinds of developers: those who quickly adapted and picked up new languages, and those who wanted to remain "Python devs." The latter group didn’t have a great time moving forward.

What I don't like about the "Python + Framework + Postgres" argument is that it often lacks context. This is a formidable combination for starting a business and finding PMF. But unless you've seen Python and Postgres completely break under 100k RPS and petabyte-scale data, it's hard to understand the limitations just from words. Python is fantastic, but it has its limits and there are cases where it absolutely doesn't work. This “single language everywhere” mindset is how we ended up with JavaScript on the backend and desktop.

Anyone can write Python, and with LLMs, there's not much of a moat around knowing a single language. There's also no reason not to familiarize yourself with others, since it broadens your perspective. Of course, some businesses scale quite well with Python or JavaScript. But my point isn't to abandon Python. It's to gain experience in other languages so that when people criticize Python’s build tools, you can genuinely empathize with those concerns. Otherwise, comments like “Python tooling is fine” from people who have mostly worked with only Python are hard to take seriously.

12. x187463 ◴[] No.44376067[source]
run script

"missing x..."

pip install x

run script

"missing y..."

pip install y

> y not found

google y to find package name

pip install ypackage

> conflict with other package

realize I forgot a venv and have contaminated my system python

check pip help output to remember how to uninstall a package

clean up system python

create venv at cwd

start over

...

</end of time>

replies(2): >>44378459 #>>44381518 #
13. linsomniac ◴[] No.44378102[source]
I've been a python dev for nearly 3 decades and feel that uv is removing a lot of the rough edges around dependency management. So maybe "problem" is the wrong word; I've been able to solve dependency management issues usually without too much trouble, I have also spent a significant amount of time dealing with them. For close to a decade I was managing other peoples Python environments on production systems, and that was a big mess, especially with trying to ensure that they stayed updated and secure.

If you don't see what the fuss is about, I'm happy for you. Sounds like you're living in a fairly isolated environment. But I can assure you that uv is worth a lot of fussing about, it's making a lot of our lives a lot easier.

14. arcanemachiner ◴[] No.44378236[source]
Create a virtual environment:

python3 -m venv venv

Activate the virtual environment:

source venv/bin/activate

Deactivate the virtual environment:

deactivate

replies(1): >>44379071 #
15. SAI_Peregrinus ◴[] No.44378459{3}[source]
Thankfully some newer systems will error by default if you try to mess with them via pip instead of your system's package manager. Easy to override if you want to, and saves a lot of effort fixing accidental screw ups.
16. petersellers ◴[] No.44379071{3}[source]
Or: `uvx ruff`

Which one is easier to run, especially for someone who doesn't use python everyday?

replies(1): >>44379559 #
17. arcanemachiner ◴[] No.44379559{4}[source]
The one they definitely won't have to re-learn in a few years.
replies(2): >>44380496 #>>44391723 #
18. petersellers ◴[] No.44380496{5}[source]
It's still easier if you use virtual environments so infrequently that you have to look up how to do it every time.
19. psunavy03 ◴[] No.44381518{3}[source]
>realize I forgot a venv and have contaminated my system python

>check pip help output to remember how to uninstall a package

>clean up system python

>create venv at cwd

>start over

This hits disturbingly close to home.

replies(1): >>44383554 #
20. whattheheckheck ◴[] No.44383554{4}[source]
This is like seeing someone complain they have to turn their computer on to do work
21. bjornasm ◴[] No.44391546[source]
So if you have a big project that is 4 years old and you are going to run it in a new .venv, what do you do?
22. fastasucan ◴[] No.44391723{5}[source]
Oh, I am fine re-learning an equivalent of `uvx ruff` every few years, thats not too bad.