diff options
author | Andy Schwerin <schwerin@10gen.com> | 2012-03-20 11:45:59 -0400 |
---|---|---|
committer | Andy Schwerin <schwerin@10gen.com> | 2012-03-22 16:32:56 -0400 |
commit | 245468533a48c850d7d894950b047d9252707629 (patch) | |
tree | 845782c4b0dca71989cc274608af927e6625a9c7 /buildscripts | |
parent | 6501a582a0bd97cd126b0257b29e7749869a95cc (diff) | |
download | mongo-245468533a48c850d7d894950b047d9252707629.tar.gz |
SERVER-5140: Short-circuit smoke_python_name() if the running python interpreter is new enough.
This version is for the master branch.
There's no reason to search for another version of the python interpreter if the
running version is at least the minimum supported version, and this stops a build
hang.
Diffstat (limited to 'buildscripts')
-rw-r--r-- | buildscripts/utils.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/buildscripts/utils.py b/buildscripts/utils.py index 15020feff34..413f22681af 100644 --- a/buildscripts/utils.py +++ b/buildscripts/utils.py @@ -155,10 +155,13 @@ def which(executable): return executable def find_python(min_version=(2, 5)): - # if this script is being run by py2.5 or greater, - # 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. + try: + if sys.version_info >= min_version: + return sys.executable + except AttributeError: + # In case the version of Python is somehow missing sys.version_info or sys.executable. + pass + version = re.compile(r'[Pp]ython ([\d\.]+)', re.MULTILINE) binaries = ('python27', 'python2.7', 'python26', 'python2.6', 'python25', 'python2.5', 'python') for binary in binaries: @@ -168,12 +171,12 @@ def find_python(min_version=(2, 5)): match = version.search(stream) if match: versiontuple = tuple(map(int, match.group(1).split('.'))) - if versiontuple >= (2, 5): + if versiontuple >= min_version: return which(binary) except: pass - raise Exception('could not find suitable Python (version >= %s)' % '.'.join(min_version)) + raise Exception('could not find suitable Python (version >= %s)' % '.'.join(str(v) for v in min_version)) def smoke_command(*args): # return a list of arguments that comprises a complete |