Repository navigation
fix(uv): read and write workspace uv.lock in lock() .run target - #4343
Merged
Merged
Conversation
Verify that running a uv.lock .run target writes uv.lock to the workspace root and preserves existing locked versions when upgrading a single package. Refs bazel-contrib#4339
Explain why pyproject.toml and uv.lock must be restored after test_project_lock_run_updates_existing_lock_in_workspace.
Unlike `uv pip compile`, `uv lock` has no output path flag and always reads and writes `uv.lock` in the project directory alongside `pyproject.toml`. Previously, running the `.run` target for a `uv.lock` output executed `uv lock` directly in the runfiles directory without including the existing workspace lock file in runfiles or writing the updated lock file back to `BUILD_WORKSPACE_DIRECTORY`. As a result, commands like `bazel run //:lock.run -- --upgrade-package foo` ignored the existing workspace `uv.lock` and wrote output only inside the runfiles tree. Include the existing lock file in the `.run` target's runfiles and update the wrapper scripts to resolve `uv.lock` against the workspace output path. When `uv.lock` in runfiles is already a writable symlink to the workspace output file, execute `uv` in place; otherwise, stage the runfiles tree in a temporary directory and write the resulting lock file back to the workspace. Fixes bazel-contrib#4339
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Unlike
uv pip compile,uv lockhas no output path flag and alwaysreads and writes
uv.lockin the project directory alongsidepyproject.toml. Previously, running the.runtarget for auv.lockoutput executed
uv lockdirectly in the runfiles directory withoutincluding the existing workspace lock file in runfiles or writing the
updated lock file back to
BUILD_WORKSPACE_DIRECTORY. As a result,commands like
bazel run //:lock.run -- --upgrade-package fooignoredthe existing workspace
uv.lockand wrote output only inside therunfiles tree.
Include the existing lock file in the
.runtarget's runfiles andupdate the wrapper scripts to resolve
uv.lockagainst the workspaceoutput path. When
uv.lockin runfiles is already a writable symlink tothe workspace output file, execute
uvin place; otherwise, stage therunfiles tree in a temporary directory and write the resulting lock file
back to the workspace.
Fixes #4339