Fix/poetry install double zip #714
Closed
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.
Description
Fixes a bug where Lambda layers created with poetry_install, pip_requirements, or npm_requirements incorrectly included both the installed dependencies AND the original source files, even when using
patterns to exclude them.
Root Cause
The module was unconditionally executing a "zip" step for the source path after dependency managers had already zipped their installed packages. This caused both the dependencies and pattern-filtered
source files to be included in the final zip.
Changes
• Modified package.py line 886 to make the source path zip step conditional
• Added comment explaining the logic
• Updated examples/build-package/main.tf to demonstrate using patterns with poetry_install
• Now only zips source path when NOT using dependency managers (pip_requirements, poetry_install, or npm_requirements)
• Dependency managers handle their own zipping correctly
Testing
Created a test Lambda layer with:
• Source files: src/, test/, terraform/, Makefile
• Poetry dependencies: requests and its dependencies
• Patterns excluding all source files
Before fix: Zip contained both python dependencies AND source files
After fix: Zip contains ONLY python/ directory with dependencies
Verified with:
Breaking Changes
None. This fix makes the module behave as users would expect when using patterns with dependency managers.
Related Issues
This addresses the issue where patterns were ineffective at excluding source files when poetry_install, pip_requirements, or npm_requirements were enabled.