Erotemic
Erotemic

Reputation: 5228

Conditionally install from requirements.txt depending on the Python Implementation

I have a requirements.txt file that specifies an optional dependency that fails when running on PYPY.

I know you can make lines in the requirements.txt file conditional on Python version, or operating system. For instance:

Following dependencies will only be installed for Python 3.5+ and on Win32 respectively

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

However, I'm looking for a way to only install a package if the platform.python_implementation() is CPython, or not PYPY.

Upvotes: 2

Views: 1987

Answers (1)

Erotemic
Erotemic

Reputation: 5228

As I was writing this, I found the answer:

https://www.python.org/dev/peps/pep-0508/

The previous code can be augmented as follows:

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

Upvotes: 4

Related Questions