Serverless-python-requirements: General requirements.txt while using Per-function requirements

Created on 16 Apr 2018  ยท  5Comments  ยท  Source: UnitedIncome/serverless-python-requirements

Can i keep a general requirements.txt file in the root folder for all general functions and an additional unique requirements.txt for a specific function in a module folder?
e.g

โ”œโ”€โ”€ serverless.yml
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ functions.py
โ”œโ”€โ”€ specialFunctionWithAdditionalRequirments
โ”‚ โ”œโ”€โ”€ requirements.txt
โ”‚ โ””โ”€โ”€ specialFunction.py

package:
  individually: true

functions:
  func1:
    handler:  functions.func1
  func2:
    handler:  functions.func2
 special:
    handler: specialFunction.handler
    module: specialFunctionWithAdditionalRequirments

attempting to do "sls deploy -f func1" in this configuration resulted me in:

Cannot read property 'artifact' of undefined error
TypeError: Cannot read property 'artifact' of undefined
    at values.forEach (.../node_modules/serverless-python-requirements/lib/inject.js:113:21)
    at Array.forEach (<anonymous>)
    at ServerlessPythonRequirements.injectAllRequirements (.../node_modules/serverless-python-requirements/lib/inject.js:99:8)

Edit: there is an high chance that the error (bug) is more general to 4.0.0 and unrelated to the per-function feature, as it happens to me also after reverting back to one requirement.txt file

enhancement help wanted

All 5 comments

There isn't currently anyway to do that afaik. As for the errors. I suspect that's #161

Thanks, can you please mark as a feature request.
I believe it is a very common scenario for many.

Yup, I consider #161 a bug since this is behavior that should be supported. As you can see on that issue, it's actually the result of an upstream bug in serverless itself. I'm going to close this issue since it's a duplicate and I don't want too much clutter in the issue backlog. Subscribe to #161 and serverless/serverless#4898 to get updates on progress.

What i meant was a request for a feature that support a general (root directory) requirements.txt file with optional additional requirement.txt files in modules.

Ohhh, right!! Yes, I'll reopen and add the right tag.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cdimitroulas picture cdimitroulas  ยท  4Comments

xedef picture xedef  ยท  3Comments

davegravy picture davegravy  ยท  5Comments

JulienMarliac picture JulienMarliac  ยท  3Comments

amadensor picture amadensor  ยท  3Comments