Skip to main content
 首页 » 编程设计

Openshift V3 : update setuptools before build 上的 Python 2.7

2025年05月04日3298°冷暖

安装cryptography 包时出现以下错误:

Invalid environment marker: platform_python_implementation != 'PyPy' 

看来升级 setuptools 可以解决这个问题。有没有一种方法可以编辑 Build Config YAML 文件,以便 pip install --upgrade setuptools 在构建任何包之前运行?

请您参考如下方法:

运行:

oc set env bc/yourappname UPGRADE_PIP_TO_LATEST=true 

参见:

执行此操作时,它应该更新 pip、setuptools 和 wheel 包。

唯一的问题是此时,setuptools 和 wheel 等所做的更改还没有在基于 RHEL 的 Python S2I 镜像中更新。因此,如果您使用的是 OpenShift Container Platform(由 OpenShift Online 使用),它将无法按要求工作。

解决方法的第一个选择是暂时使用基于 CentOS 的图像:

oc new-app centos/python-27-centos7~https://url-to-your-repo 

第二个选项是在您的源代码存储库中添加一个名为 .s2i/bin/assemble 的可执行 shell 脚本,其中包含:

#!/bin/bash 
 
set -eo pipefail 
 
pip install --upgrade pip setuptools wheel 
 
/usr/libexec/s2i/assemble 

这将代替正常的 assemble 脚本执行,允许您安装更新。然后运行原始的 assemble 脚本。