1 Answer 1
Not sure if there's some special setting, but this in the beginning of setup.py might help:
import sys
if sys.version_info.major < 3:
print("I'm only for 3, please upgrade")
sys.exit(1)
answered Nov 14, 2012 at 18:59
bereal
34.7k8 gold badges65 silver badges111 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
abarnert
+1. The idiomatic way to check version is
sys.version_info < (3,) (I believe that's primarily to make it easier to change to (3, 1) when you want to drop support for 3.0), but I don't think this is really confusing or less readable.dom0
FWIW I think it's more idiomatic to write it as
.major < 3, because that immediately assigns meaning to the number. This doesn't really matter in this instance, since it's pretty obvious anyway, though ;)Explore related questions
See similar questions with these tags.
lang-py
pip2.x will not see your app, or will refuse to install it, or just so that runningpython2.7 setup.py installwill give an error? For the latter, bereal's solution is perfect.pip2 differently, you can always ask for that info later; no need to learn all that now if you don't plan to use it.Programming Language :: Python :: 3instead of the defaultProgramming Language :: Pythonclassifier. Anyway, all this is really just to preventeasy_install,pip, or whatever future tool comes out of thedistribute2project from having to download your package before giving an error.