Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(lambda-python): requirements.txt created in the entry folder when using Poetry #20296

Closed
gshpychka opened this issue May 11, 2022 · 2 comments
Closed
Assignees
Labels
@aws-cdk/aws-lambda-python bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@gshpychka
Copy link
Contributor

gshpychka commented May 11, 2022

Describe the bug

lambda-python supports requirements.txt, poetry.lock and pipfile to define the function dependencies. If using poetry.lock, a requirements.txt file is created in the entry folder after bundling. This is an unexpected side effect.

Expected Behavior

cdk synth does not modify the contents of the function entry folder.

Current Behavior

requirements.txt is created in the entry folder alongside pyproject.toml and poetry.lock.

Reproduction Steps

Create a PythonFunction that points to a directory with pyproject.toml and poetry.lock. Run cdk synth. Inspect the contents of the directory.

Possible Solution

Don't create files in the entry directory, or clean them up after bundling. Or better yet, do the packaging in a docker container. Unless this is already supposed to be happening?

Additional Information/Context

No response

CDK CLI Version

2.23.0

Framework Version

2.23.0

Node.js Version

18.1.0

OS

Linux

Language

Python

Language Version

No response

Other information

The docs mention this somewhat:

Packaging is executed using the Packaging class, which:

Infers the packaging type based on the files present.
If it sees a Pipfile or a poetry.lock file, it exports it to a compatible requirements.txt file with credentials (if they're available in the source files or in the bundling container).
Installs dependencies using pip.
Copies the dependencies into an asset that is bundled for the Lambda package.

I believe the code that does this is here:

exportCommand: `poetry export --with-credentials --format ${DependenciesFile.PIP} --output ${DependenciesFile.PIP}`,

@gshpychka gshpychka added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 11, 2022
@corymhall
Copy link
Contributor

duplicate of #19231

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda-python bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants