Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong version of packages installed when multiple python runtimes in same serverless config #764

Open
3 tasks done
svonderohe opened this issue Mar 16, 2023 · 0 comments
Open
3 tasks done

Comments

@svonderohe
Copy link

svonderohe commented Mar 16, 2023

Are you certain it's a bug?

  • Yes, it looks like a bug

Are you using the latest plugin release?

  • Yes, I'm using the latest plugin release

Is there an existing issue for this?

  • I have searched existing issues, it hasn't been reported yet

Issue description

I have a serverless config with functions that have multiple python versions (python3.7 and python3.8)
However, serverless-python-requirements is packaging python3.8 version of the packages for the python3.7 function. This is causing exceptions when the function is deployed to aws lambda:

Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed.
...
Original error was: No module named 'numpy.core._multiarray_umath'

(The python 3.8 version of numpy cannot be run by python 3.7)
When I separate the python3.7 functions and python3.8 functions into separate serverless files the problem goes away (but, that isn't very maintainable)

The issue seems to be cause by a single options.pythonBin shared between all functions

const pipCmd = [options.pythonBin, '-m', 'pip', 'install'];

(This would be fixed if each function had it's own pythonBin)

Service configuration (serverless.yml) content

service: minimal-service

provider:
  name: aws
  runtime: python3.8
  region: us-west-2

package:
  individually: true

functions:
  function37:
    handler: handle.handler
    module: function37/src
    runtime: python3.7

  function38:
    handler: handle.handler
    module: function38/src

plugins:
  - serverless-python-requirements

Command name and used flags

serverless package (or serverless deploy)

Command output

N/A

Environment information

Framework Core: 3.28.1 (local) 3.28.1 (global)
Plugin: 6.2.3
SDK: 4.3.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant