Skip to content

Commit

Permalink
Remove weasyprint patch
Browse files Browse the repository at this point in the history
WeasyPrint accepted our patch so latest version works as is.
  • Loading branch information
kalekseev committed Feb 5, 2021
1 parent d7ae8a5 commit df6396c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 24 deletions.
4 changes: 2 additions & 2 deletions fonts/layer_builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ cd /tmp
yumdownloader \
dejavu-sans-fonts \
dejavu-fonts-common \
xorg-x11-fonts-Type1 $@
xorg-x11-fonts-Type1 "$@"

rpmdev-extract *rpm
rpmdev-extract -- *rpm

mkdir /opt/fonts
cp -P -r /tmp/*/usr/share/fonts/* /opt/fonts
Expand Down
2 changes: 1 addition & 1 deletion weasyprint/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def lambda_handler(event, context):
content_type = "application/pdf"
method = "write_pdf"
elif ext == ".png":
content_type = f"image/png"
content_type = "image/png"
method = "write_png"
else:
raise ValueError("File extension {ext} is not supported.")
Expand Down
27 changes: 7 additions & 20 deletions weasyprint/layer_builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,24 @@ yumdownloader --resolve \
libblkid.x86_64 \
glib2.x86_64 \

rpmdev-extract *rpm
rpmdev-extract -- *rpm

mkdir /opt/lib
cp -P -r /tmp/*/usr/lib64/* /opt/lib
# pixbuf need list loaders cache
# https://developer.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-query-loaders.html
PIXBUF_BIN=$(find /tmp -name gdk-pixbuf-query-loaders-64)
export GDK_PIXBUF_MODULEDIR=$(find /opt/lib/gdk-pixbuf-2.0/ -name loaders)
GDK_PIXBUF_MODULEDIR=$(find /opt/lib/gdk-pixbuf-2.0/ -name loaders)
export GDK_PIXBUF_MODULEDIR
$PIXBUF_BIN > /opt/lib/loaders.cache
# pixbuf need mime database
# https://www.linuxtopia.org/online_books/linux_desktop_guides/gnome_2.14_admin_guide/mimetypes-database.html
cp -r /usr/share/mime /opt/lib/mime

export RUNTIME=$(echo $AWS_EXECUTION_ENV | cut -d _ -f 3)
mkdir -p /opt/python/lib/$RUNTIME/site-packages
python -m pip install weasyprint -t /opt/python/lib/$RUNTIME/site-packages

# fix dlopen(3) calls
cd /opt/python/lib/$RUNTIME/site-packages
sed -i "s/'libgdk_pixbuf-2.0.so'/'libgdk_pixbuf-2.0.so.0'/" cairocffi/pixbuf.py
sed -i "s/'libgobject-2.0.so'/'libgobject-2.0.so.0'/" cairocffi/pixbuf.py
sed -i "s/'libglib-2.0.so'/'libglib-2.0.so.0'/" cairocffi/pixbuf.py
sed -i "s/'libcairo.so'/'libcairo.so.2'/" cairocffi/__init__.py
sed -i "s/'libfontconfig.so'/'libfontconfig.so.1'/" weasyprint/fonts.py
sed -i "s/'libpangoft2-1.0.so'/'libpangoft2-1.0.so.0'/" weasyprint/fonts.py
sed -i "s/'libgobject-2.0.so'/'libgobject-2.0.so.0'/" weasyprint/fonts.py
sed -i "s/'libpango-1.0.so'/'libpango-1.0.so.0'/" weasyprint/fonts.py
sed -i "s/'libpangocairo-1.0.so'/'libpangocairo-1.0.so.0'/" weasyprint/fonts.py
sed -i "s/'libgobject-2.0.so'/'libgobject-2.0.so.0'/" weasyprint/text.py
sed -i "s/'libpango-1.0.so'/'libpango-1.0.so.0'/" weasyprint/text.py
sed -i "s/'libpangocairo-1.0.so'/'libpangocairo-1.0.so.0'/" weasyprint/text.py
RUNTIME=$(echo "$AWS_EXECUTION_ENV" | cut -d _ -f 3)
export RUNTIME
mkdir -p "/opt/python/lib/$RUNTIME/site-packages"
python -m pip install "weasyprint>=52.2" -t "/opt/python/lib/$RUNTIME/site-packages"

cd /opt
zip -r9 /out/layer.zip lib/* python/*
2 changes: 1 addition & 1 deletion wkhtmltox/layer_builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ yumdownloader --resolve \
expat.x86_64 \
libuuid.x86_64 \

rpmdev-extract *rpm
rpmdev-extract -- *rpm
mkdir /opt/lib
cp -P -r /tmp/*/usr/lib64/* /opt/lib/

Expand Down

0 comments on commit df6396c

Please sign in to comment.