根据Python实现,有条件地从requirements.txt安装

根据Python实现,有条件地从requirements.txt安装,python,Python,我有一个requirements.txt文件,指定在PYPY上运行时失败的可选依赖项 我知道您可以根据Python版本或操作系统在requirements.txt文件中设置条件行。例如: 以下依赖项将分别安装在Python 3.5+和Win32上 black;python_version > '3.5' colorama;platform_system=="Windows" 但是,我正在寻找一种方法,仅当platform.python_implementation(

我有一个requirements.txt文件,指定在PYPY上运行时失败的可选依赖项

我知道您可以根据Python版本或操作系统在requirements.txt文件中设置条件行。例如:

以下依赖项将分别安装在Python 3.5+和Win32上

black;python_version > '3.5' 
colorama;platform_system=="Windows"

但是,我正在寻找一种方法,仅当
platform.python_implementation()
是CPython或不是PYPY时才安装软件包。

在撰写本文时,我找到了答案:

前面的代码可以扩充如下:

black;python_version > '3.5' and platform_python_implementation=="CPython"
colorama;platform_system=="Windows"