nficano / python-lambda

A toolkit for developing and deploying serverless Python code in AWS Lambda.
ISC License
1.5k stars 227 forks source link

including executable binaries #33

Open kzuberi opened 7 years ago

kzuberi commented 7 years ago

Lambda supports execution of binary programs within a lambda function, and python-lambda is a convenient way to package and upload these wrapped in a python interface. This almost works perfectly as is, except that python zip doesn't preserve executable bits when creating the package, and AWS requires these to be set or else the binary will fail with a permissions error.

I worked around this for my own use case by hacking helpers.py based on code in this stackexchange question, hardcoding special handling for my executable file. A more complete solution might be to check the executable flags on the files when packaging and preserve when building the zip archive, or alternatively allow the config file to specify a list of executables for special handling during packaging.

Thanks for the useful package!

rstms commented 7 years ago

I ran into this issue as well, and found a simple way to get binaries working:

example config.yaml:

...
# Build options
build:
  source_directories: lib,bin #  source_directories: lib,bin # a comma delimited list of directories in your project root that contains source to package.