Is there any way to tell setuptools or distribute to require a package on a specific platform?
In my specific case, I\'m using readline, which comes as par
Other answers are valid and probably more convenient if supporting old setuptools versions is required, but there have been some advancements:
Recent versions of setuptools accept PEP 508 style dependency specification:
setup(
# ...
install_requires=[
'pyreadline; platform_system == "Windows"',
],
)
Choose the right parameter:
install_requires: what other distributions are needed for the current distribution to work correctlyextras_require: a dictionary mapping the names of optional features to a list of their requirementssetup_requires: other distributions that need to be present for the setup script to run correctly
Note: projects listed in setup_requires will NOT be automatically installed. They are simply downloaded to the ./.eggs directory if they’re not locally available already.There is also an alternative way for supplying these parameters through setup.cfg file. See the documentation for more info.
PEP 518 introduces a new and more capable way of specifying setup_requires in pyproject.toml file:
[build-system]
# Minimum requirements for the build system to execute.
requires = ['setuptools>"38.3.0"', 'wheel'] # PEP 508 specifications.
The feature was implemented in pip 10.0.0b1. Using it one will be able to automatically install and update build system requirements.