I have a module that works both on python 2 and python 3. In Python<3.2 I would like to install a specific package as a dependency. For Python>=3.2.
Something like:
install_requires=[
"threadpool >= 1.2.7 if python_version < 3.2.0",
],
How can one make that?
setuptools
has support for this using environment markers.Use of this is detailed in the official documentation. Based on the change log was added in v20.5, but the implementation wasn't stable until v20.8.1 (which was only a gap of 15 days).
Original Answer (still valid, but might be deprecated in the future):
setuptools
has support for this using within theextras_require
argument.The format is the following:
It will support the other comparison operators.
Sadly, it is not mentioned in the documentation. While looking for answers, I found PEP-426 talking about "environment markers". With that phrase I was able to find a setuptools ticket with the following comment:
This has been discussed here, it would appear the recommend way is to test for the Python version inside your
setup.py
usingsys.version_info
;