diff --git a/packages/@aws-cdk/aws-s3-deployment/lambda/build.sh b/packages/@aws-cdk/aws-s3-deployment/lambda/build.sh index 4e32b8ad2986c..0a33096a32672 100755 --- a/packages/@aws-cdk/aws-s3-deployment/lambda/build.sh +++ b/packages/@aws-cdk/aws-s3-deployment/lambda/build.sh @@ -14,8 +14,8 @@ rm -f ${bundle_out} # prepare staging staging="$(mktemp -d)" -rm -fr ${staging} -mkdir -p ${staging} +piptemp="$(mktemp -d)" +trap "rm -rf ${staging} ${piptemp}" EXIT echo "staging lambda bundle at ${staging}..." @@ -25,7 +25,10 @@ rsync -av src/ "${staging}" cd ${staging} # install python requirements -pip3 install -r requirements.txt -t . +# Must use --prefix to because --target cannot be used on +# platforms that have a default --prefix set. +pip3 install --prefix ${piptemp} -r ${staging}/requirements.txt +mv ${piptemp}/lib/python*/site-packages/* . # create archive zip -qr ${bundle_out} .