astral-sh / uv

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

Updating pyproject.toml version during build results in incorrect version in uv.lock #7994

Open david-waterworth opened 2 hours ago

david-waterworth commented 2 hours ago

This is more an observation rather than an issue.

I'm using a ci tool that parses commit history, generates the "next" version and updates the version in pyproject.toml (the tool is python-semantic-release).

What I just noticed was, since python-semantic-release updates pyproject.toml when it performs a build, once the build has finished uv.lock contains the "wrong" version for the project, i.e.

[[package]]
name = "my-package"
version = "0.2.1.dev0"
source = { virtual = "." }

Since python-semantic-release bumped the version to "0.2.1". To fix I added uv sync && build.sh && git add uv.lock - this updates the lock file and stages it (with the other files python-semantic-release modifies.

I'm not sure if this causes more problems than it fixes, but I thought I'd mention it - I think in general it's probably a better practice to generate tags based on the pyproject.toml->project.version rather than the other way around?

zanieb commented 2 hours ago

Thanks for the report.

I think @charliermarsh has some context on this.