- 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
import os
import os.path
+import re
import string
import sys
import traceback
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
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()