Peak operating system requirements

Is it possible to have special OS requirements in the pip.txt requirements file?

For example: I have a dependency on readline, so if you are installing on windows (or OSX) then you need to use pyreadline. If it is linux, then I do not want to force install.

+4
source share
2 answers

In the end, adding an OS check in the setup.py file is what I found for other people. Example:

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

link to the complete setup.py file with sample code

+5
source

In pip>=6You can do this by using the "markers of the environment", as defined in the PEP-496 :

Here are some examples of such markers in the require.txt file:

pywin32 >=1.0 ; sys_platform == 'win32'
unittest2 >=2.0,<3.0 ; python_version == '2.4' or python_version == '2.5'
backports.ssl_match_hostname >= 3.4 ; python_version < '2.7.9' or (python_version >= '3.0' and python_version < '3.4')

, setup.py , PyWin32 , Windows:

setup(
  install_requires=["pywin32 > 1.0 : sys.platform == 'win32'"],
  setup_requires=["pywin32 > 1.0 : sys.platform == 'win32'"]
  )
0

All Articles