-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat(managers): add support for uv universal locking #30756
feat(managers): add support for uv universal locking #30756
Conversation
Just a note that I intentionally only linked the issue instead of using "Closes" in the PR description because the PR only adds support for the universal locking strategy, not the |
Co-authored-by: Michael Kriese <[email protected]>
Hi! Is there an example somewhere of what's required to configure Dependenbot to work with the various forms of uv outputs? I'd love to add a guide to our official documentation. Also, as a note in response to the summary comment, we also support universal locking in |
Not yet, this PR only implements universal locking, but there was some discussion to support
You mean Renovate, not Dependabot, right? 😄 Since Renovate will look for an |
🎉 This issue has been resolved in version 38.41.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Thanks for clarifying. That sounds good to me.
Sorry! Yes haha, lost in my pile of notifications. That's great to know — I'll give it a try so I can write a quick guide. Thanks again! |
If you need an example, there's https://github.com/mkniewallner/showcase-uv-renovate, and if you need more details, happy to help, we can discuss about that in Astral's Discord (same username as in GitHub) in order to not spam maintainers here 🙂 |
Changes
Note
If this contribution is accepted, we'll need to install uv in https://github.com/containerbase/base, but before doing that, I'd prefer to know if the contribution will be accepted. I also have a question related to how the dependency should be installed, that could determine how the dependency will be installed in the Docker image.
This PR implements partial support for uv by focusing on supporting the new universal lock file (
uv.lock
).Context
uv supports 2 ways of managing and locking dependencies:
requirements.txt
fileuv.lock
fileIn both situations, it is possible to define the dependencies using PEP 621, which Renovate already supports.
Although the linked issue mostly discussed supporting the
pip-tools
way of locking dependencies (because at the time, universal locking did not exist), this PR is about implementinguv.lock
support.For the implementation, I took a lot of inspiration from the already implemented
pdm
manager, which is really close to uv, since both tools support universal locking and are built on top of PEP 621.Things implemented
Support for
[tool.uv.dev-dependencies]
Documentation: https://docs.astral.sh/uv/concepts/dependencies/#development-dependencies
We basically have a single list of dependencies (unlike PDM, which allows creating multiple groups of development dependencies)
Updating lock file on
pyproject.toml
updatesDocumentation: https://docs.astral.sh/uv/reference/cli/#uv-lock
uv supports updating specific packages in the lock file by passing
--upgrade-package
option. Weirdly, the option is not listed in the documentation above, but we can find it in the CLI:Lock file maintenance
Documentation: https://docs.astral.sh/uv/reference/cli/#uv-lock
uv supports refreshing the lock file for transitive dependencies by using
uv lock --upgrade
. Unlike PDM,--upgrade
is necessary here, because by default, uv will not try to refresh any dependency in the lock file, unless there are updates inpyproject.toml
that require to update it. So by passing--upgrade
, we update all dependencies to the latest available while respecting ranges inpyproject.toml
.Things let aside for now
As mentioned earlier, this PR does not implement the 2nd way of locking dependencies: in a
pip-tools
fashion. We could also support this later though, but I believe we'd first have to define how to differentiate uv from the realpip-tools
, since both use the same output file.Another thing I did not add is the extraction of locked versions in
extractLockedVersions
method, which is something implemented in PDM. Although it should not be too complex to handle, I intentionally chose to let it aside for now, because the universal lock file is quite new, and could be subject to changes as projects start switching to it. Case in point, the most recent breaking change to it was last week (astral-sh/uv#5861). Once things stabilise, we can of course add support for reading lock files (which AFAIK is used for detecting dependencies with CVEs and raising PRs to update them?).Finally, there is also a notion of workspaces that is, from all I know, similar to Yarn or Cargo. I don't know how much work it would be to support that in Renovate, but that can probably be handled later, especially if this is subject to change.
Documentation (please check one with an [x])
How I've tested my work (please select one)
I have verified these changes via:
I've tested the changes over https://github.com/mkniewallner/showcase-uv-renovate.
This shows:
[tool.uv.dev-dependencies]
(Update dependency mypy to v1.11.1 mkniewallner/showcase-uv-renovate#4)[project.dependencies]
(Update dependency pydantic to v2.8.2 mkniewallner/showcase-uv-renovate#5)[project.optional-dependencies]
(Update dependency click to v8 mkniewallner/showcase-uv-renovate#8)