Created
October 17, 2016 09:31
-
-
Save christianklotz/ccd0515372abd6845b445d6ff3e61c80 to your computer and use it in GitHub Desktop.
Create Python app package for Amazon AWS Lambda including Google's ortools dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DEST_DIR=$(dirname $(realpath -s $0)); | |
echo "Copy all native libraries..."; | |
mkdir -p ./lib && find $directory -type f -name "*.so" | xargs cp -t ./lib; | |
echo "Create package..."; | |
zip -r dist.zip your-python-script.py lib; | |
rm -r ./lib; | |
echo "Add dependencies from $VIRTUAL_ENV to $DEST_DIR/dist.zip"; | |
cd $VIRTUAL_ENV/lib/python2.7/site-packages; | |
zip -ur $DEST_DIR/dist.zip ./**; | |
# ortools isn't found by Lamda with this setup, so instead of the line above | |
# I also tried the following approach, moving ortools directly into the | |
# project root. This works to the extend that it finds the ortools but it is | |
# still unable to import pywrapcp. | |
# Hence the following lines are purely included for illustration purposes. | |
# | |
# zip -ur $DEST_DIR/dist.zip ./**; -x "ortools*"; | |
# | |
# cd $(find $directory -type d -name "ortools")/..; | |
# zip -ur $DEST_DIR/dist.zip ortools; | |
cd $VIRTUAL_ENV/src/jal; | |
zip -ur $DEST_DIR/dist.zip ./**; | |
echo "Done"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment