serverless / serverless-python-requirements

⚡️🐍📦 Serverless plugin to bundle Python packages
MIT License
1.09k stars 289 forks source link

fix: mixing runtimes and architectures #815

Closed stijzermans closed 4 months ago

stijzermans commented 5 months ago

while running a setup where combining Python and NodeJS lambda's, I ran into a couple of issues:

1) packaging of mixed runtime (as mentioned in #688 ) would lead to the following error:

STDOUT:  Error:
[OperationalError: ENOENT: no such file or directory, scandir '.serverless/requirements'] {
  cause: [Error: ENOENT: no such file or directory, scandir '.serverless/requirements'] {
    errno: -2,
    code: 'ENOENT',
    syscall: 'scandir',
    path: '.serverless/requirements'
  },
  isOperational: true,
  errno: -2,
  code: 'ENOENT',
  syscall: 'scandir',
  path: '.serverless/requirements'
}

2) dockerizePip image would always default to provider.runtime / provider.architecture which would lead to the following error:

Running "docker run --rm <mounts> -u 0 public.ecr.aws/sam/build-nodejs18.x:latest-arm64 python -m pip install -t /var/task/ -r /var/task/requirements.txt --cache-dir /var/useDownloadCache" failed with: "/usr/bin/python: No module named pip"

therefore I've adjusted 1) zipping to be to only be performed on either functions which runtimes are specifically python, or no runtime is set and provider.runtime is python3.

2) to take function options as argument for retrieving the docker image.

stijzermans commented 5 months ago

cc: @pgrzesik - would be great if you could take a look whenever time permits!