diff options
author | Steven Knight <knight@baldmt.com> | 2003-08-29 04:39:46 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2003-08-29 04:39:46 (GMT) |
commit | e7bd1d71888221071e97778d1dbd31750d9874cd (patch) | |
tree | be754e403c1f1c2868c9a1a71091108d543b8176 | |
parent | 2980620964ae712daafc70b7a715351dddbc54ba (diff) | |
download | SCons-e7bd1d71888221071e97778d1dbd31750d9874cd.zip SCons-e7bd1d71888221071e97778d1dbd31750d9874cd.tar.gz SCons-e7bd1d71888221071e97778d1dbd31750d9874cd.tar.bz2 |
Fix EnsurePythonVersion's handling of alphanumeric version strings.
-rw-r--r-- | src/CHANGES.txt | 2 | ||||
-rw-r--r-- | src/engine/SCons/Script/SConscript.py | 12 | ||||
-rw-r--r-- | test/EnsureVersion.py | 42 |
3 files changed, 53 insertions, 3 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 0b1b03e..3aad3c1 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -28,6 +28,8 @@ RELEASE X.XX - XXX - Support #include when there's no space before the opening quote or angle bracket. + - Accomodate alphanumeric version strings in EnsurePythonVersion(). + RELEASE 0.92 - Wed, 20 Aug 2003 03:45:28 -0500 diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index ee53a63..0f9daa7 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -49,6 +49,7 @@ import SCons.Node.Alias import os import os.path +import re import string import sys import traceback @@ -453,11 +454,16 @@ class Options(SCons.Options.Options): def __init__(self, files=None, args=arguments): SCons.Options.Options.__init__(self, files, args) -def CheckVersion(major,minor,version_string): +def CheckVersion(major, minor, version_string): """Return 0 if 'major' and 'minor' are greater than the version in 'version_string', and 1 otherwise.""" - version = string.split(string.split(version_string, ' ')[0], '.') - if major > int(version[0]) or (major == int(version[0]) and minor > int(version[1])): + try: + v_major, v_minor, v_micro, release, serial = sys.version_info + except AttributeError: + version = string.split(string.split(version_string, ' ')[0], '.') + v_major = int(version[0]) + v_minor = int(re.match('\d+', version[1]).group()) + if major > v_major or (major == v_major and minor > v_minor): return 0 else: return 1 diff --git a/test/EnsureVersion.py b/test/EnsureVersion.py index d24e010..c4005e0 100644 --- a/test/EnsureVersion.py +++ b/test/EnsureVersion.py @@ -76,4 +76,46 @@ sys.exit(0) test.run(status=2) +test.write('SConstruct', """\ +import sys +delattr(sys, 'version_info') +sys.version = '2.3b1 (#0, Feb 24 2003, 19:13:11)\\n' +EnsurePythonVersion(1,3) +sys.exit(0) +""") + +test.run() + +test.write('SConstruct', """\ +import sys +delattr(sys, 'version_info') +sys.version = '2.3+ (#0, Feb 24 2003, 19:13:11)\\n' +EnsurePythonVersion(2,2) +sys.exit(0) +""") + +test.run() + +test.write('SConstruct', """\ +import sys +delattr(sys, 'version_info') +sys.version = '2.3b1 (#0, Feb 24 2003, 19:13:11)\\n' +EnsurePythonVersion(2,3) +sys.exit(0) +""") + +test.run() + +test.write('SConstruct', """\ +import sys +delattr(sys, 'version_info') +sys.version = '2.3b1 (#0, Feb 24 2003, 19:13:11)\\n' +EnsurePythonVersion(2,4) +sys.exit(0) +""") + +test.run(status=2) + + + test.pass_test() |