-
-
Notifications
You must be signed in to change notification settings - Fork 643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pants generate-lockfiles
to use uv
for dependency resolution
#20679
Comments
Duplicate of pex-tool/pex#2371 - see the discussion there, and feel free to join in! |
I'm not so sure this is a duplicate. Pants need not use Pex lock files. It could use uv directly and only support what it supports (for now); i.e.only locking for the current interpreter, not supporting subsetting and not supporting packed layout. It may be worth the effort to re-understand all the crazy things Pex does to support shortcomings in Pants perf. Perhaps there have been sandboxing improvements to obviate the need for packed layout or even the need for subsetting. Perhaps using multiple platforms specific lock files instead of 1 universal lock file makes sense, etc. |
Reopening this to discuss the possibility of Pants using uv directly, outside of Pex. |
Cross-posting my comment to the above linked issue here:
|
Or Python becomes Javascripty with an increasingly fragmented set of tools which all purport to solve the same suite of problems, claiming to be faster/est, while not supporting 100% compatibility with the solution they want to dethrone. Oh how I sincerely hope that's not the case. Don't get me wrong, we've got a lot of tools to solve the same set of problems, but it's not quite JS levels yet. |
|
Jeez it feels so ridiculous to write dependencies back to a temporary pyproject.toml for uv to read. It'd be nice to directly invoke uv with a list of deps. Alternatively, it would be so much easier to take the stance that pants only enables |
I thought Where are you dropping The alternative is to try and integrate |
uv can read requirements.txt. We use it as a first-pass resolver to check if there is a solution and to quickly iterate until there is. When we know there is solution, then we run pants/pex to generate the actual lockfile (independent of uv). This works well today, without changes to pants, and saves us a lot of time / makes resolving actually feasible. Alternatively, it would probably also be easily possible to just feed the output of uv as “requirements.txt” to pex and generate a compatible lockfile that way. That should be fast because everything is already resolved and pinned exactly by uv. But haven’t tried this variant yet. (To a small extent I do this by taking a few results from uv’s output as constraints.txt for pex in the above approach, to speed it up.) This should work today, also without changes to pants. |
TBH I'm still unclear on where the performance benefits of |
I was wondering the same. Haven’t digged into it yet. But it’s day and night. I think the big difference is when you have a deeply hidden conflict. That’s where pex takes an open ended amount of time (I give up before it finishes) whereas uv figures it out quickly. It looked a little bit like pex might just get stuck on some “bad” package versions so that it benefited from lower bounds. Maybe it also runs into throttling from the PyPI server (unlike uv which makes fewer requests when not considering multiplatform). |
Pex is delegating to Pip for the resolver algorithm, just to be clear. So yeah, I guess it really is the resolver. |
uv is fast because they do the same thing as pip's Then then don't care too much about backwards compatibility of older wheel, egg formats, or even older Python versions. The rest is then the faster resolver and aggressive caching. |
@benjyw I was taking a stab at uv subsystem in pants for lockfile generation and consumption, and I was referencing how poetry locks worked in pants before pex which is why I mentioned writing to a tmp pyproject.toml: |
Ran into this, which might have some light insights into practical uv perf benefits, and why: Is there a world where, instead of starting with
|
Is your feature request related to a problem? Please describe.
As of now the pip python dependency resolution using
pants generate-lockfiles
can take a very long time. In order to improve the overall UX ofpants
the alternative dependency resolvers can be made available to the users.Describe the solution you'd like
https://github.com/astral-sh/uv is designed to be pip-compatible package installer and resolver. From my experience the
uv pip compile
is orders of magnitude faster than default pip dependency resolution.Describe alternatives you've considered
This feature could be implemented as opt-in, given the maturity stage of the
uv
project.The text was updated successfully, but these errors were encountered: