uv
uv copied to clipboard
feat: lock dependencies that are not relevant to the platform the compile is running on
uv 0.1.44
With this requirements input file:
jupyterlab==4.2.0
running this command: uv pip compile --generate-hashes --no-header --no-strip-extras --python-version=3.11.9 -o foo.txt foo.in on a Linux host generates a foo.txt file that does not contain 'appnope'.
appnope is a platform_system specific dependency of the ipykernel:
https://github.com/ipython/ipykernel/blob/v6.29.4/pyproject.toml#L33
'appnope;platform_system=="Darwin"',
We want to lock our requirements, but having contributors run uv pip compile for every distinct platform seems like unnecessary toil. Even if a perfect job isn't possible, doing a usually-good-enough job would be fantastic.
Concrete proposal:
- when encountering a platform specific conditional dependency, include it, preserving the condition. And for its dependencies, whatever they are, inject the same condition unless an alternative path leads to their unconditional inclusion.
You can do something like this to build a single requirements file for both platforms: https://github.com/astral-sh/uv/issues/2679#issuecomment-2068208602
Unclear if we'll offer something like this in the pip compile API directly. We're already building platform-agnostic resolution support atop lockfiles. Perhaps as part of that we'll offer outputting a requirements file.
You can do something like this to build a single requirements file for both platforms: #2679 (comment)
What about allowing the use of multiple --platform flags? Obviously it would need to do environment markers.
By the way: we now support --universal which does this!
(We may eventually support allowing multiple --python-platform flags as a less general solution.)
I noticed --universal but I don't want everything as it slows down the whole run. I've gone from 1 hour on pip-compile to 5 minutes with UV because of this!