diff options
author | Dan Crosta <dcrosta@10gen.com> | 2012-01-31 11:19:42 -0500 |
---|---|---|
committer | Dan Crosta <dcrosta@10gen.com> | 2012-01-31 11:20:02 -0500 |
commit | 4770f74e6ee5dd6ebc42f0733fa6e25f08192d98 (patch) | |
tree | fc4972a15de1c0a5fe45375fe57d7b66747624b6 | |
parent | 9bbdf6d86baf675796cdce0610c4d3de39583079 (diff) | |
download | mongo-4770f74e6ee5dd6ebc42f0733fa6e25f08192d98.tar.gz |
even better python version/binary detection
-rw-r--r-- | SConstruct | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/SConstruct b/SConstruct index ac08deffe92..3d2fecb693a 100644 --- a/SConstruct +++ b/SConstruct @@ -821,9 +821,22 @@ def smoke_python_name(): # then we assume that "python" points to a 2.5 or # greater python VM. otherwise, explicitly use 2.5 # which we assume to be installed. - if sys.version_info >= (2, 5): - return "python" - return "python2.5" + import subprocess + version = re.compile(r'[Pp]ython ([\d\.]+)', re.MULTILINE) + binaries = ['python', 'python2.5', 'python2.6', 'python2.7', 'python25', 'python26', 'python27'] + for binary in binaries: + try: + # py-2.4 compatible replacement for shell backticks + output = subprocess.Popen([binary, '--version'], stdout=subprocess.PIPE).communicate()[0] + match = version.search(output) + if match and float(match.group(1)) >= 2.5: + return binary + except Exception, e: + print >> sys.stderr, "error detecting suitable python:", e + pass + + # if that all fails, fall back to "python" + return "python" def setupBuildInfoFile( outFile ): version = utils.getGitVersion() |