How to include Pango/Cairo to use Weasyprint with my Django app?
Context
I have deployed a simple Django app which uses Weasyprint.
Expected Behavior
The app should produce PDF files, upon request.
Actual Behavior
The app prints the following exception: cannot load library 'pango-1.0': pango-1.0: cannot open shared object file: No such file or directory. Additionally, ctypes.util.find_library() did not manage to locate a library called 'pango-1.0'
Weasyprint requires Pango and Cairo, which normally need to be installed on the host machine.
Possible Fix
@Prasengupta has published a github repo, weasyprint_for_awslambda to help with importing Pango and Cairo. Unfortunately, I dont fully understand what needs to be done. He says I should Step 1: Download the zip file from this repository. Step 2: Include your main handler file in the folder and zip it, upload the zip folder to aws lambda., but I don't know how to do step 2 with Zappa.
Steps to Reproduce
- Create a Django app which uses Weasyprint to produce a PDF, for example :
weasyprint.HTML("https://www.google.com/").write_pdf() - Push to AWS
- Witness the error message
Your Environment
- Zappa version used: 0.47.0
- Python version: 3.6
- The output of
pip freeze: https://justpaste.it/7j2sx
Source: Miserlou/Zappa