Skip to content Skip to sidebar Skip to footer

Operating-system Specific Requirements With Pip

Is it possible to have OS specific requirements in pip's requirements.txt file? For example: I have a dependency on readline, therefore, if installing on windows (or OSX), then pyr

Solution 1:

You can do this with "Environment Markers" as specified in PEP-508:

Here's an example of using such a marker inside a requirements.txt:

pyreadline==2.1; platform_system == "Windows"

Similarly, in a setup.py:

setup(
    ...
    install_requires=['pyreadline; platform_system == "Windows"'],
)

Solution 2:

In the end, adding the OS check in the setup.py is what I've found other people using. Ex:

install_requires = [
        "parsedatetime >= 1.1.2",
        "colorama >= 0.2.5",
        "pycrypto >= 2.6"
        ] + ["pyreadline >= 2.0"] if "win" in sys.platform else [],

link to full setup.py with example code


Post a Comment for "Operating-system Specific Requirements With Pip"