Skip to content
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

uv lock --locked and dynamic versioning collide. #9233

Closed
mjpieters opened this issue Nov 19, 2024 · 2 comments
Closed

uv lock --locked and dynamic versioning collide. #9233

mjpieters opened this issue Nov 19, 2024 · 2 comments

Comments

@mjpieters
Copy link

As part of our CI lint check, we validate that the lock file is current:

uv lock --locked 2>/dev/null || {
    echo -e '\033[0;31mThe lockfile at `uv.lock` needs to be updated. To update the lockfile, run `uv lock`\033[0m'.
    exit 1
} >&2

This project is built using hatch, together with the hatch-vcs plugin to set the version from the current git context:

[project]
# ...
dynamic = ["version"]

[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[tool.hatch.build.hooks.vcs]
version-file = "_version.py"

[tool.hatch.version]
source = "vcs"

This does mean that the version changes with every commit. Currently. this projects version is 0.15.2.dev3+g417c8ff, meaning it is 3 commits away from the nearest tagged commit (which was tagged v0.15.1), and the current commit hash (shortened) is 417c8ff. Once a commit is tagged for a new version (say, 0.16.0) the project version reflects this. Thats great, because this lets our developers create a release version from a PR branch and test it against other projects simply by updating a dependency elsewhere to point to a development release.

However, uv lock puts this version in the lock file too. And so uv lock --locked fails for every new commit. And we could update the lock file, commit it, and... the lock file would immediately be outdated because with a new commit, there's a new commit hash and a new version, that's not going to match the lock file.

Is there any way we can avoid this problem?

@my1e5
Copy link
Contributor

my1e5 commented Nov 19, 2024

Lots of discussion about this topic here:

@charliermarsh
Copy link
Member

Yeah let's keep the conversation over there. Right now VCS-based dynamic versions are in conflict with locking.

@charliermarsh charliermarsh closed this as not planned Won't fix, can't repro, duplicate, stale Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants