Question

I have a Python package that I would like to make into a wheel. On Python 2, the package uses the ipaddr library. On Python 3, it uses the built-in ipaddress library. For the sdist package, I check the sys.version_info in setup.py to set the requirements based on the Python version. Unfortunately, this does not seem to work with wheels. Is it possible to do a conditional dependency based on the Python version with a wheel?

Était-ce utile?

La solution

As of Wheel 0.24.0, this is support using extra_require. For instance

setup(
    ...,
    extras_require={':python_version=="2.6"':: ['ipaddr']},
    ...
)

This is documented in the "Defining Conditional Dependencies" of the Wheel documentation and follows PEP 426.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top