From 245468533a48c850d7d894950b047d9252707629 Mon Sep 17 00:00:00 2001 From: Andy Schwerin Date: Tue, 20 Mar 2012 11:45:59 -0400 Subject: 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. --- buildscripts/utils.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'buildscripts') 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 -- cgit v1.2.1