serverless-python-requirements
serverless-python-requirements copied to clipboard
Dependencies are not packaged for the lambda which has Individual packaging (per lambda, not the top level).
Are you certain it's a bug?
- [X] Yes, it looks like a bug
Are you using the latest plugin release?
- [X] Yes, I'm using the latest plugin release
Is there an existing issue for this?
- [X] I have searched existing issues, it hasn't been reported yet
Issue description
When individual packaging is defined per lambda, dependencies are not packaged for that lambda.
I.e. We have a such function in serverless.yml:
MyIndividualFunction:
module: src.my_module
handler: my_file.my_handler
package:
individually: true
and such project structure:
src/
-- my_module/
---- my_file.py
---- requirements.txt
And libraries listed in requirements.txt
are not packaged to the final MyIndividualFunction.zip
Service configuration (serverless.yml) content
N/A
Command name and used flags
N/A
Command output
N/A
Environment information
Framework Core: 1.83.0
Plugin: 3.8.4
SDK: 2.3.2
Components: 2.34.9
"serverless-python-requirements": "5.1.0"
Hey @amediantsev, thanks for reporting and sorry you've run into trouble there. It looks like you're using an outdated version of the Framework and not up-to-date version of the plugin. Could you please upgrade to latest versions if possible first? It might be that the issue is already resolved in older versions of the plugin
@pgrzesik Thanks for responding. You are correct. I have updated the framework and the plugin, but the result is the same, unfortunately.
Current versions:
Framework Core: 3.25.0 (local) 3.25.0 (global) Plugin: 6.2.2 SDK: 4.3.2
{... "serverless-python-requirements": "^6.0.0" ...}
@amediantsev I am not sure if you still have this issue.
What worked for me is removing serverless-python-requirements
cache.
I found the directory by running this:
SLS_DEBUG=* sls package --verbose
Line specifying the cache dir starts with Using static cache of requirements found at
Hope that helps
@amediantsev did you get to solve this thing? I am using the latest version and the packed zip includes the whole project (instead the module only) and does not include any of the requirements that exist in the req file inside the module defined. any solution for this? where does it says it is supported?
I have the same issue trying to deploy inside a Bitbucket pipeline. Also, I'm using serverless compose to deploy two services:
- the first containing a single lambda function
- the second containing 3 lambda functions
The packaging for the second fails for 1 single lambda but randomly: sometimes it works, sometimes don't.
I'm using the most recent versions and nodejs 20.
Hey @jacksoncassimiro 👋 Sorry you've ran into trouble. I've tried to reproduce this bug but I was not successful in my attempts. Would you have the ability to share a reproducible example by any chance? Does it only fail when working Compose?
If anyone else could provide a concrete repro example, I would be grateful 🙇
@jacksoncassimiro I was facing the same issue. You need to add individually: true
at the top level package:
key in serverless.yaml file. The steps I followed are:
service: my-service-${self:custom.version}
custom:
version: ${env:VERSION}
pythonRequirements:
dockerizePip: true
noDeploy:
- moto # This is already available in aws lambda so no need to deploy.
- boto3 # This is already available in aws lambda so no need to deploy.
package:
individually: true # This is important to package requirements individually with all lambdas.
patterns:
- "!.venv/**"
- "!.venv*/**"
- "!package*.json"
- "!.vscode"
- "!Docker/**"
- "tests/**"
- "!buckets/**"
- "!node_modules/**"
- "!openapi.yml"
- "!models.yaml"
- "!serverless.doc.yaml"
- "!serverless-*.yaml"
Its working fine for me.