aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <ctismer@gmail.com>2015-10-13 21:11:26 +0200
committerChristian Tismer <ctismer@gmail.com>2015-10-13 21:11:26 +0200
commit81cd1a4557cb9ba41fd19813f20657201180d5a7 (patch)
tree173543a0021673ae922ffdf3aee28e2a86b51ec9
parent89b35c19f00f3356185cc195be3cbbbd5b16a22d (diff)
ensure that the python version used is supported
-rw-r--r--setup.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/setup.py b/setup.py
index 02ea588c..1da0ba79 100644
--- a/setup.py
+++ b/setup.py
@@ -123,6 +123,25 @@ def get_extension_folder(ext):
folder = difflib.get_close_matches(ext, maybe)[0]
return folder
+# make sure that setup.py is run with an allowed python version
+def check_allowed_python_version():
+ import re
+ pattern = "'Programming Language :: Python :: (\d+)\.(\d+)'"
+ supported = []
+ with open(__file__) as setup:
+ for line in setup.readlines():
+ found = re.search(pattern, line)
+ if found:
+ major = int(found.group(1))
+ minor = int(found.group(2))
+ supported.append( (major, minor) )
+ this_py = sys.version_info[:2]
+ if this_py not in supported:
+ print("only these python versions are supported:", supported)
+ sys.exit(1)
+
+check_allowed_python_version()
+
# Declare options
OPTION_DEBUG = has_option("debug")
OPTION_RELWITHDEBINFO = has_option('relwithdebinfo')