To prevent import, put this at the top of the module:
import sys if sys.version_info[0] < 3: raise ImportError('Python < 3 is unsupported.')
To prevent installation, put this at the top of setup.py :
import sys if sys.version_info[0] < 3: sys.exit('Python < 3 is unsupported.')
This will also fail before validation if you use syntax that is incompatible with Python 2 since the module will be parsed before running. Finding this out may be redundant to support "non-Python 2 support".
But I actually did not see this in practice. Most attendants simply say that it is supported and does not interfere with the verification.
source share