Python: Improve dependency recipe lock file handling and version normalization#6752
Merged
knutwannheden merged 4 commits intomainfrom Feb 17, 2026
Merged
Python: Improve dependency recipe lock file handling and version normalization#6752knutwannheden merged 4 commits intomainfrom
knutwannheden merged 4 commits intomainfrom
Conversation
Bare version strings like `2.28.0` passed to `AddDependency`, `UpgradeDependencyVersion`, `UpgradeTransitiveDependencyVersion`, and `ChangeDependency` were concatenated directly with the package name, producing invalid PEP 508 specs such as `requests2.28.0`. A shared `PyProjectHelper.normalizeVersionConstraint()` now prefixes `>=` when no comparison operator is present. Also parse `uv.lock` in `PythonRewriteRpc.parseProject()` via the standard `TomlParser` so that lock files are included in the source set and can be updated by dependency-management recipes.
The Python RPC server's handle_parse_project extracted relative_to from the request but never forwarded it, producing absolute source paths. Now defaults to project_path (matching the JS implementation) and passes it through so source paths are relative. Also strengthened ParseProjectIntegTest to assert full relative paths.
When regenerating uv.lock after dependency changes, seed the temp directory with the existing lock file so `uv lock` performs a minimal update rather than re-resolving every dependency from scratch. Also extend TomlParser to accept uv.lock files, allowing the scanner phase of dependency recipes to capture existing lock contents.
Move lock file maps (updatedLockFiles, existingLockContents) from per-recipe accumulators into a shared PythonDependencyExecutionContextView. This allows sequential recipes in a CompositeRecipe to correctly build on each other's lock regeneration results. Also extract maybeUpdateUvLock helper in PyProjectHelper that handles idempotent uv.lock updates with content normalization for round-trip stability across recipe cycles.
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.
Summary
2.28.0→>=2.28.0) across all dependency recipes to produce valid PEP 508 specsuv.lockfiles via the standardTomlParserso lock files are included in the source set and can be updated by dependency recipesuv lockregeneration with existing lock file content for minimal, deterministic updates instead of full re-resolutionPythonDependencyExecutionContextView, so sequential recipes in aCompositeRecipecorrectly build on each other's lock regeneration resultsmaybeUpdateUvLockhelper for idempotent uv.lock updates with content normalization for round-trip stability across recipe cyclesTest plan
AddDependencyTest—addDependencyWithBareVersion,uvLockRegenerationWorks,twoAddDependenciesInSequence(CompositeRecipe with shared lock state)ChangeDependencyTest—bareVersionNormalizedUpgradeDependencyVersionTest—bareVersionNormalizedUpgradeTransitiveDependencyVersionTest—bareVersionNormalizedInConstraint,bareVersionNormalizedInFallbackastral-sh/pyx-auth-action— bothpyproject.tomlanduv.lockcorrectly updated