Configure Python package to install dependencies only for specific combinations of Python version and platform
PEP 508 introduced environment markers which let you specify conditions for whether a package should be installed. These can be used inside the install_requires
or setup_requires
argument in setup.py
, or within the requirements.txt
.
The most simple example is:
This would only install argparse
if the Python version is lower than 2.7
.
However PEP 508 details many more enivonment markers, and specifies the grammar for combining these. For example:
This would only install baz
if the Python version is greater than or equal to 3.6
, and the system is Linux.