Is it possible to express a platform-specific dependency in setup.py without building platform-specific versions of my egg?

For sdist, egg and wheel release from : https://setuptools.readthedocs.io/en/latest/userguide/dependency_management.html#platform-specific-dependencies

Sometimes a project might require a dependency to run on a specific platform. This could to a package that back ports a module so that it can be used in older python versions. Or it could be a package that is required to run on a specific operating system. This will allow a project to work on multiple different platforms without installing dependencies that are not required for a platform that is installing the project.

setup(
    name="Project",
    ...
    install_requires=[
        'enum34 ; python_version<"3.4"',
        'pywin32 >= 1.0 ; platform_system=="Windows"'
    ]
)

Leave a Comment