2

With WeasyPrint, I need to do the following in order to get the required libraries:

sudo apt-get install build-essential python3-dev python3-pip python3-setuptools python3-wheel python3-cffi libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info

I have added this to my GitHub triggers as it builds:

    - name: Install WeasyPrint dependencies
  run: |
    cd /home
    sudo apt-get install build-essential python3-dev python3-pip python3-setuptools python3-wheel python3-cffi libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info

And when I view the build logs, it shows that it is successful; however, the Python app will still not start, saying it could not find the required libraries:

OSError: no library called "cairo" was found
no library called "libcairo-2" was found
cannot load library 'libcairo.so.2': libcairo.so.2: cannot open shared 
No such file or directory
cannot load library 'libcairo.2.dylib': libcairo.2.dylib: cannot open 
No such file or directory
cannot load library 'libcairo-2.dll': libcairo-2.dll: cannot open 
No such file or directory

I tried to do what another user did (successfully, it seems) and just log in via SSH to install it directly, but when I try to do this, apt-get throws 404 errors, for example:

(antenv) root@13f25a3adfa1:/tmp/8d947bb726491c3# apt-get install libcairo2
Reading package lists... Done
Building dependency tree
[. . .]
Fetched 4156 kB in 0s (4207 kB/s)
E: Failed to fetch http://security.debian.org/debian-security/pool/updates/main/libx/libx11/libx11-data_1.6.4-3+deb9u3_all.deb  404  Not Found
E: Failed to fetch http://security.debian.org/debian-security/pool/updates/main/libx/libx11/libx11-6_1.6.4-3+deb9u3_amd64.deb  404  Not Found
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Does Azure App Service not allow you to do this anymore? I'm at a loss as to what to try next.

EDIT: So I was able to get all of the dependencies to add by SSHing into the machine and running apt-get update first. However, I still run into the issue of my Python app still not being able to run. I see the following errors, even though the libraries installed:

2021-07-19T14:43:06.741297128Z OSError: no library called "cairo" was found
    2021-07-19T14:43:06.741300828Z no library called "libcairo-2" was found
    2021-07-19T14:43:06.741304429Z cannot load library 'libcairo.so.2': libcairo.so.2: cannot open shared object file: No such file or directory
    2021-07-19T14:43:06.741308229Z cannot load library 'libcairo.2.dylib': libcairo.2.dylib: cannot open shared object file: No such file or directory
    2021-07-19T14:43:06.741311929Z cannot load library 'libcairo-2.dll': libcairo-2.dll: cannot open shared object file: No such file or directory
  • not pip install? – LarryX Jul 16 '21 at 19:22
  • pip isn't relevant here. The libraries that need to be installed cannot be installed with pip, which is why I am trying to use apt-get to install them first, just like their documentation suggests. – David W. Green Jul 19 '21 at 13:20
  • @DavidW.Green were you able to solve this? Appreciate it's been over a year... Having the same issue with installing dependencies and banging my head against a wall. – benedwards44 Mar 02 '23 at 02:48
  • @benedwards44, unfortunately, no. I gave up and went with another PDF library altogether that didn't require dependencies. Sorry I wasn't of more help! – David W. Green Mar 03 '23 at 19:55
  • @DavidW.Green thanks for the response, have explored GitHub actions, Azure pre/post scripts and custom containers and no luck either. I believe a custom container would work but really didn't want to go down that path... So thinking a different PDF library - I have a very simple PDF requirement anyway. – benedwards44 Mar 06 '23 at 04:30

1 Answers1

0

https://learn.microsoft.com/en-us/azure/app-service/configure-language-python

App Service's build system, called Oryx, performs the following steps when you deploy your app if the app setting SCM_DO_BUILD_DURING_DEPLOYMENT is set to 1: ....

I believe it can be put in requirements.txt, or PRE_BUILD_COMMAND setting

LarryX
  • 591
  • 2
  • 7