Skip to content

Instantly share code, notes, and snippets.

@dmvianna
Last active October 21, 2022 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmvianna/8a835bb69b0781c6411330257fbcee85 to your computer and use it in GitHub Desktop.
Save dmvianna/8a835bb69b0781c6411330257fbcee85 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
#
# This script uses poetry to bundle all the dependencies
# found in `pyproject.toml` into a zip file that can be
# then uploaded to AWS Lambda.
#
if [ -f artifact.zip ] ; then
rm artifact.zip
fi
if [ -d ./package ] ; then
rm -rf ./package
fi
mkdir -p ./package
poetry export \
--without-hashes \
--without test,dev \
--format requirements.txt \
--output ./package/requirements.txt
pip install \
--requirement ./package/requirements.txt \
--target ./package
cp -r ./<MODULE NAME> ./package
cd ./package
zip \
--recurse-paths \
../artifact.zip \
. \
--exclude "*.pyc" \
--exclude ".*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment