在Google Build中使用python包

时间:2019-06-14 19:53:38

标签: python google-cloud-platform google-cloud-build

我尝试在requirements.txt中下载python-ldap==3.2.0。但是,我需要these dependencies。我应该如何使用Google Build下载这些文件?我尝试了以下操作,但出现了错误:

Step #0 - "Dependency install": E: Unable to locate package libsasl2-dev
Step #0 - "Dependency install": E: Unable to locate package python-dev
Step #0 - "Dependency install": E: Unable to locate package libldap2-dev
Step #0 - "Dependency install": E: Unable to locate package libssl-dev
Step #0 - "Dependency install": Building dependency tree...
Step #0 - "Dependency install": Reading state information...
Finished Step #0 - "Dependency install"
2019/06/14 12:51:21 Step Step #0 - "Dependency install" finished
2019/06/14 12:51:21 status changed to "ERROR"
ERROR
ERROR: build step 0 "ubuntu" failed: exit status 100
2019/06/14 12:51:21 Error updating docker credentials: failed to update docker credentials: signal: killed
2019/06/14 12:51:21 Failed to delete homevol: exit status 1
2019/06/14 12:51:24 Build finished with ERROR status

cloudbuild.yaml

steps:
# Install Dependencies
- name: 'ubuntu'
  id: Dependency install
  args: ['apt-get', 'install',
         'libsasl2-dev', 'python-dev', 'libldap2-dev', 'libssl-dev']
# Install Python Dependencies
- name: 'python'
  id: Pip install
  args: ['pip3', 'install', '-r', 'requirements.txt', '--user']

然后我尝试了

- name: 'ubuntu'
  id: Dependency install
  args: ['apt-get', 'update', '&&', 'apt-get', 'install',
         'libsasl2-dev', 'python-dev', 'libldap2-dev', 'libssl-dev']

但这也失败了。

1 个答案:

答案 0 :(得分:1)

Google Cloud Functions仅接收您的源代码和一个requirements.txt文件,以指示其使用的python依赖项。
GCF管理器会在内部自动将这些依赖项安装在将运行您的功能的python环境上,将系统库安装到GCF环境中,但可以使用可用的库(here is the list)。您所需的库libldap2不可用。因此,您可以在他们的问题跟踪器上打开问题以寻求帮助。

现在,尽管它不能为您提供帮助,但GC Build上的错误正在发生,因为步骤之间仅共享工作区(起始工作目录及其内部的所有内容)。每个步骤都会启动一个docker容器,该容器具有name参数中指定的图像以及已安装的工作空间。
一个不共享系统更改的更明显的证明是,一步使用Ubuntu,另一步使用CentOS,另一步使用Alpine。每个系统库的系统库都非常不同,因此显然不会共享。