#!/bin/bash if [ -z "$1" ]; then echo "Usage: $0 [...]" echo "set DEST_ZIP to change the location of the output file" echo "DEST_ZIP defaults to lambda.zip in the current directory" exit 1 fi TEMP_DIR="$(mktemp -d)" DEST_DIR="$PWD" DEST_ZIP="${DEST_ZIP:-$DEST_DIR/lambda.zip}" test -f "$DEST_ZIP" && { echo "Error: $DEST_ZIP already exists" exit 1 } ( cd "$TEMP_DIR" mkdir -p python python3 -m venv venv source venv/bin/activate pip install -U "$@" -t ./python zip -r "$DEST_ZIP" python echo "Lambda package created at: $DEST_ZIP" ) rm -rf "$TEMP_DIR" echo " # if you want to test locally, you can do this in your python file: import sys sys.path.insert(0,'./lambda.zip/python') # now import whatever package directly from the zip "