Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 pyreadline is a requirement. If it's linux, then I don't want to force an install.

like image 220
Alex Avatar asked Apr 15 '13 09:04

Alex


People also ask

Can I put pip in requirements txt?

Use the pip install -r requirements. txt command to install all of the Python modules and packages listed in your requirements. txt file. This saves time and effort.

How do you fix error you must give at least one requirement to install see pip help install?

You must give at least one requirement to install (see "pip help install") You are using pip version 9.0. 1, however version 9.0. 3 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.


1 Answers

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"'],
)
like image 187
John Carter Avatar answered Oct 26 '22 04:10

John Carter