Package Exports
- serverless-python-requirements
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (serverless-python-requirements) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Serverless Python Requirements
A Serverless v1.0 plugin to automatically bundle dependencies from
requirements.txt
and make them available in your PYTHONPATH
.
Install
npm install --save serverless-python-requirements
Add the plugin to your serverless.yml
:
plugins:
- serverless-python-requirements
Cross compiling!
Compiling non-pure-Python modules or fetching their manylinux wheels is
supported on non-linux OSs via the use of Docker and the
docker-lambda image.
To enable docker usage, add the following to your serverless.yml
:
custom:
pythonRequirements:
dockerizePip: true
Dealing with Lambda's size limitations
To help deal with potentially large dependencies (for example: numpy
, scipy
and scikit-learn
) there is support for compressing the libraries. This does
require a minor change to your code to decompress them. To enable this add the
following to your serverless.yml
:
custom:
pythonRequirements:
zip: true
and add this to your handler module before any code that imports your deps:
import unzip_requirements
Manual invocations
The .requirements
and requirements.zip
(if using zip support) files are left
behind to speed things up on subsequent deploys. To clean them up, run
sls requirements clean
. You can also create them manually with
sls requirements install
.
Credit
This plugin is influenced by serverless-wsgi from @logandk. I however wanted a simpler pip install process. It now also supports bundling packages without the wsgi handler.