Serverless Python Requirements Plugin
npm install serverless-py-requirementsyaml
plugins:
- sls-py-pkg
custom:
pythonRequirements:
# These options are optional, only set them if you know what you're doing
# excludeDefaults: false
# cmd: pip install -r requirements.txt -r common_utils/requirements.txt -t .
# pipArgs: >
# --index-url=https://pypi.org/simple
# --secondary-url=https://pypi.org/simple
shared:
common_utils:
source: ../shared
# if no functions specified, it will apply it to all
functions:
- hello
exclude:
- pyarrow/srcfunctions:
hello:
module: .
handler: handler.hello
zip: true # the handler now has to unzip its own "requirements.zip"
`
---
> Note> Duplicate modules are not supported, for good practices
> filter using the
exclude options, don't use ~~Packaging patterns~~>In handler.py, shared code can be imported like this:
`py
from common_utils import shared_resource
``