diff --git a/examples/build-package/main.tf b/examples/build-package/main.tf index ec843b68..28828cfe 100644 --- a/examples/build-package/main.tf +++ b/examples/build-package/main.tf @@ -471,6 +471,15 @@ module "lambda_layer_poetry" { path = "${path.module}/../fixtures/python-app-poetry" poetry_install = true poetry_tmp_dir = "${path.cwd}/../fixtures" + # Patterns work correctly with poetry_install - only poetry files are needed + # The installed dependencies will be in the layer, but source files will be excluded + patterns = [ + "!ignore_please.txt", # Exclude this file + "!index.py", # Exclude source code + "pyproject.toml", # Include poetry config + "poetry.lock", # Include lock file + "poetry.toml" # Include poetry settings + ] } ] hash_extra = "extra-hash-to-prevent-conflicts-with-module.package_dir" diff --git a/package.py b/package.py index 3261a282..da6dc223 100644 --- a/package.py +++ b/package.py @@ -880,7 +880,10 @@ def commands_step(path, commands): required=True, tmp_dir=claim.get("npm_tmp_dir"), ) - if path: + + # Only zip the source path if not using dependency managers + # (pip/poetry/npm handle their own zipping) + if path and not (pip_requirements or poetry_install or npm_requirements): path = os.path.normpath(path) step("zip", path, prefix) if patterns: