Skip to content

Instantly share code, notes, and snippets.

@nickovs
Last active December 27, 2023 19:02
Show Gist options
  • Save nickovs/f097c577df90bdeb98ea0127c60e3462 to your computer and use it in GitHub Desktop.
Save nickovs/f097c577df90bdeb98ea0127c60e3462 to your computer and use it in GitHub Desktop.
A script for building a version of the Zbar library suitable for running in an AWS Lambda instance
#!/bin/bash
# Clear out old images
[ -d "lib" ] && rm -r lib
cat <<EOF > tmp_recipe.sh
# This is the actual container-side recipe
yum groupinstall -y "Development Tools"
cd /root
git clone https://github.com/mchehab/zbar.git
cd zbar
autoreconf -vfi
./configure --prefix=/usr --without-xshm --without-xv --without-jpeg --without-imagemagick --without-gtk --without-python --without-qt --disable-video
make
mkdir -p /build/lib
cp -a zbar/.libs/libzbar.so* /build/lib
EOF
# Run the recipe in an Amazon Linux 2 container
docker run --rm -it -v $(pwd):/build amazonlinux:2 bash /build/tmp_recipe.sh
rm tmp_recipe.sh
@yopicon2
Copy link

Hi! thanks for the code. do you know how to convert this files into a layer? my lamda function keeps saying "errorMessage": "Unable to import module 'lambda_function': No module named 'pyzbar'"

@nickovs
Copy link
Author

nickovs commented Jul 28, 2022

@yopicon2 I've not tried converting this into a layer, primarily because layers hugely slows down the Lambda container start time. Instead I used the fix that is in NaturalHistoryMuseum/pyzbar#41 which the maintainers merged into one of their branches some time ago but have never got around to releasing :-(

@yopicon2
Copy link

yopicon2 commented Aug 1, 2022

Thanks very much!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment