python-lambda
python-lambda copied to clipboard
Package libraries with native dependencies
I am developing on macOS and want to package Pillow. I have installed and downloaded pillow from an ec2 instance and want it to be packaged instead of the one in site-packages. Right now only way to do is to include PIL in source_directories and uninstall it via pip before packaging. Is there a better way to do it?
I ran into the same problem today and fell back to using a docker container for building the function package. Something along the lines of the following Dockerfile would do the job (e.g. for Ubuntu 16.04):
FROM ubuntu:xenial
ENV LANG C.UTF-8
RUN apt-get update --fix-missing
RUN apt-get install -y python curl git
RUN apt-get upgrade -y
RUN curl https://bootstrap.pypa.io/get-pip.py | python2
RUN pip install python-lambda
WORKDIR /build
COPY . /build/
# run your build command
CMD lambda build --requirements requirements.txt
docker build -t mylambdacontainer .
docker run -v $(pwd)/dist:/build/dist mylambdacontainer
I mount the dist directory where the packages are created as a volume on my host machine so I can have them in the same place as I would when building natively.