Skip to content

Comments

fix: add support for auto-reinstallation of local Python packages with uv#13197

Merged
czubocha merged 5 commits intomainfrom
sc-3665
Jan 7, 2026
Merged

fix: add support for auto-reinstallation of local Python packages with uv#13197
czubocha merged 5 commits intomainfrom
sc-3665

Conversation

@czubocha
Copy link
Contributor

@czubocha czubocha commented Dec 23, 2025

Closes #13169
Mitigates known uv behavior: astral-sh/uv#13876


Summary

This Pull Request enables automatic reinstallation of local Python packages when using the uv installer.

Because uv does not currently reinstall path-based dependencies even if source files change (see workaround context below), this PR introduces logic to detect local packages and explicitly force their reinstallation. This ensures that source changes are always reflected in the packaged artifacts, preventing "stale" deployments.

Main Changes

Enhanced pip.js

  • uv workaround: Implemented explicit --reinstall-package flags for local path dependencies to address uv#13876.
  • Introduced logic to detect local packages by parsing pyproject.toml and requirements.txt.

New Tests

  • uv_local_package: Added a comprehensive test case validating that source changes in a local package are correctly picked up and packaged.

@Mmarzex
Copy link
Contributor

Mmarzex commented Dec 23, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds automatic reinstallation support for local Python packages when using the uv installer to address a known uv caching issue where local packages aren't reinstalled when source files change. The implementation detects local packages by parsing pyproject.toml files and adds --reinstall-package flags to force their reinstallation.

  • Enhanced pip.js with logic to detect and force reinstall local packages
  • Added comprehensive test case validating that source changes in local packages are correctly packaged
  • Introduced TOML parsing to extract package names from pyproject.toml files

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/serverless/lib/plugins/python/lib/pip.js Added getLocalPackagesFromRequirements and getPackageNameFromPyproject functions to detect local packages and force their reinstallation with uv's --reinstall-package flag
packages/sf-core/tests/python/test.js Added test case that modifies a local package's source and verifies the changes are reflected in the packaged artifact
packages/sf-core/tests/python/tests/uv_local_package/pyproject.toml Test fixture defining a local Python package with Flask dependency
packages/sf-core/tests/python/tests/uv_local_package/serverless.yml Serverless configuration for test using uv installer
packages/sf-core/tests/python/tests/uv_local_package/handler.py Lambda handler importing and using the local package
packages/sf-core/tests/python/tests/uv_local_package/src/my_local_package/init.py Local package implementation with version information for testing
packages/sf-core/tests/python/tests/uv_local_package/uv.lock UV lock file with package dependencies including the local package as editable source

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@czubocha czubocha requested a review from eahefnawy December 23, 2025 20:20
@czubocha czubocha merged commit 19a43c2 into main Jan 7, 2026
18 checks passed
@czubocha czubocha deleted the sc-3665 branch January 7, 2026 15:32
@github-actions github-actions bot locked and limited conversation to collaborators Jan 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using uv during packing can lead to stale code deployment

3 participants