JSPM

  • Created
  • Published
  • Downloads 92170
  • Score
    100M100P100Q248744F
  • License MIT

Serverless Python Requirements Plugin

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

serverless

A Serverless v1.0 plugin to automatically bundle dependencies from requirements.txt.

Install

npm install --save serverless-python-requirements

Add the plugin to your serverless.yml:

plugins:
  - serverless-python-requirements

Adding the dependencies to sys.path

serverless-python-requirements adds a module called requirements to your puck. To easily make the bundled dependencies available, simply import it. Eg. add this to the top of any file using dependencies specified in your requirements.txt:

import requirements
# Now you can use deps you specified in requirements.txt!
import requests

Limitations

  • MacOS & Windows: For now this only works with pure Python modules unless running serverless on the same architeture as AWS (x86_64 Linux).
  • if using the package directive in serverless.yml ensure that .requirements and requirements.py are included.

Manual invocations

The .requirements and requirements.py files are left behind to simplify development. To clean them up, run sls requirements clean. You can also install them manually for local development with sls requirements install.