云构建pytest找不到Ghostscript库

Cloud build pytest Can not find Ghostscript library

我正在尝试创建一个触发器来测试函数,然后再将其部署到 cloud function。到目前为止,我设法安装了 requirements.txt 并执行了 pytest 但我收到以下错误:

/usr/local/lib/python3.7/site-packages/ghostscript/__init__.py:35: in <module>
    from . import _gsprint as gs
/usr/local/lib/python3.7/site-packages/ghostscript/_gsprint.py:515: in <module>
    raise RuntimeError('Can not find Ghostscript library (libgs)')
E   RuntimeError: Can not find Ghostscript library (libgs)

我的 requirements.txt 文件中有 ghostscript :

[...]
ghostscript==0.6
[...]
pytest==6.0.1
pytest-mock==3.3.1

这是我的 deploy.yaml

steps:
  - name: 'docker.io/library/python:3.7'
    id: Test
    entrypoint: /bin/sh
    dir: 'My_Project/'
    args:
    - -c
    - 'pip install -r requirements.txt && pytest pytest/test_mainpytest.py -v'

从回溯中,我了解到我没有在云构建上安装 ghostscript,这是事实。

有没有办法在我的 deploy.yaml 的一个步骤上安装 ghostscript

编辑-1:

所以我尝试在一个步骤中使用命令安装 ghostscript,我尝试了 apt-get gsapt-get ghostscript 但不幸的是它没有用

真正的问题是您缺少 c-library,软件包本身似乎是通过 pip 安装的。您应该使用包管理器安装该库。这是 ubuntu-based 个容器的示例:

  - name: 'gcr.io/cloud-builders/gcloud'
    entrypoint: 'bash'
    args:
      - '-c'
      - |
        apt update
        apt install ghostscript -y
        pip install -r requirements.txt
        pytest pytest/test_mainpytest.py -v