Serverless-offline: serverless-python-requirements issue

Created on 23 Jan 2019  路  5Comments  路  Source: dherault/serverless-offline

Does this plug-in works with serverless-python-requirements?
I have module in serverless.yml and requirement.txt for python, but it completely ignored.

An example of serverless-python-requirements would be great.

Thanks,
Ali

python

All 5 comments

Hi @alikian, Thanks for the issue. The plugin does not take into account serverless-python-requirements at the moment.
We would be grateful to have a PR fixing this.
Best,

As a starting point, you can run sls requirements install to tell serverless-python-requirements to install the modules into the local filesystem (which may involve it compiling C code inside a Docker container identical to the Lambda environment).

You can then set your PYTHONPATH environment variable which serverless-offline will pass to sls invoke local when it runs the Python function, for example:

PYTHONPATH=/path/to/requirements/folder sls offline start

I am not sure whether an implementation of this would better belong in serverless-offline or serverless-python-requirements. I am suspecting serverless-python-requirements would be the better place, if serverless-offline provides a hook when starting the offline environment.

It does provide a hook when starting the offline environment 馃洨

Well, the issue is a little bit more complicated because we are using:
package:

  • individually
    function:
  • module

That means our lambdas have different requirements.txt

Hmm sounds like serverless-python-requirements will need to grab the offline hook, then use Python virtual environments to set a per-function virtual environment before launching the function.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stunningpixels picture stunningpixels  路  3Comments

dnalborczyk picture dnalborczyk  路  3Comments

aldofunes picture aldofunes  路  3Comments

jormaechea picture jormaechea  路  4Comments

JimLynchCodes picture JimLynchCodes  路  4Comments