When I run `generate-lockfiles` twice in row, it s...
# general
h
When I run
generate-lockfiles
twice in row, it still takes 5-10mins and the logs imply that archives are redownloaded and packages recompiled. Shouldn't there be a cache present to avoid this?
c
The
pip
cache (used under the hood) should be preserved as a named cache. But much like doing
pip install --dry-run
twice, little to none of the resolution is cached
h
packages shouldn’t be downloaded or recompiled though
The resolving logic is repeated because resolves depend on the state of the world (specifically, what’s available in pypi at the time the resolve is run)
But if you’re certain you’re seeing downloads and wheel building repeated, that is a bug of some kind
h
And the resolve is 'slow' because of all the index lookups it needs to do, right?
And is there something we can do to maybe override the caching so info will be preserved for e.g. 1hour or a day?
c
And the resolve is 'slow' because of all the index lookups it needs to do, right?
Well dependency resolution is NP-Complete so the answers for why things are slow dependent to be complex and hinge on the interaction of various heuristics. And the implementation details matter very much in practice. To your original point. Are you seeing
generate-lockfiles
behave slower/differently than
pip
? https://github.com/pantsbuild/pants/issues/21223 also cross links a bunch of breadcrumbs
h
Well, maybe not strictly the question, but
uv pip compile
resolves the packages in 5-15 seconds.
c
Yeah, that is not quite the same thing since it isn't a 'universal' lockfile, but
uv
uses a different logarithm implemented in a different language and is generally much faster than
pip
h
It's true that pip also takes quite some time. However, in our requirements, all versions are pinned via a constraints file. So there is really not much resolving left to do. (We use
uv pip compile
to resolve, then feed that into the lockfile generation via constraints.txt)