astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
25.94k stars 761 forks source link

How to correctly automatically version bump #7672

Closed yannsartori closed 1 month ago

yannsartori commented 1 month ago

Hello,

I currently use bumpver to automatically version bump my project in CI (realistically, all this tool does from a "versioning" perspective is search and replacing). In particular, it updates the version key in my pyproject.toml file.

The flow is thus merge new feature into main as its own commit -> automatically change these files with version specifiers (just pyproject.toml) -> commit the changes as a version bump change.

However, I noticed by manually inspecting my uv.lock that it also maintains a version key for my project. I try to run all my commands with --frozen to keep my uv.lock file as unchanged as possible, so this version key can be quite out of date from the one present in pyproject.toml after a series of version bumps.

My question for you all is how to best manage this? A couple of solutions I have thought of:

  1. Just ignore this problem out right, and let the version in the uv.lock be out of date. I'm guessing this can lead to complications down the road
  2. Also make bumpver update the uv.lock file manually. Since there is a big disclaimer about not editing the lock file manually, I am hesitant to do this
  3. Regenerate the lock file after I bump the version. This seems to defeat the purpose of using a lock file at all, if I am updating it in CI.
  4. I looked into uv lock --upgrade-package NAME_OF_PROJECT. My hope is it would just update the package information in the lock file, and NOT its dependencies, but I couldn't find any exact information on its behavior.

I know there is an issue to add capabilities for uv to manage versions for you automatically (https://github.com/astral-sh/uv/issues/6298) but my question is how to manage updating versions in general without this.

zanieb commented 1 month ago

Yeah, I think you're looking for uv lock --upgrade-package <project>.

I think @charliermarsh recently fielded a similar question to this.

charliermarsh commented 1 month ago

We can probably add some docs for this.

yannsartori commented 1 month ago

Awesome, thanks for the quick reply @zanieb! I'll pursue that solution then. I'll leave this open if you guys want to create the documentation PR off this issue, but my question was answered.

charliermarsh commented 1 month ago

👍 Thanks for following up. I'll improve the docs a bit and will use this issue to track that work.