Skip to content

Instantly share code, notes, and snippets.

@okelet
Created September 16, 2022 14:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okelet/439c2f425793ecf3fe721cefa8c284d3 to your computer and use it in GitHub Desktop.
Save okelet/439c2f425793ecf3fe721cefa8c284d3 to your computer and use it in GitHub Desktop.
Simple shell script to generate a ZIP package for a script whose dependencies are defined using Poetry
#!/bin/bash
set -e
TMP_DIR=$(mktemp -d --suffix=.poetry-lambda-generate-zip)
APP_DIR=$(pwd)
rm -Rf dist
mkdir dist
poetry run pip -q --disable-pip-version-check install -t ${TMP_DIR}/package .
cd ${TMP_DIR}/package
zip -q -x "*.pyc" -x "**/__pycache__/*" -r ${APP_DIR}/dist/lambda.zip .
cd ${APP_DIR}
rm -Rf ${TMP_DIR}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment