- Allow Help() to be called multiple times, appending to the help
text each call.
+ - Allow Tools found on a toolpath to import Python modules from
+ their local directory.
+
From Steve Christensen:
- Handle exceptions from Python functions as build actions.
def Tool(name, toolpath=[], **kw):
"Select a canned Tool specification, optionally searching in toolpath."
+ oldpythonpath = sys.path
+ sys.path = toolpath + sys.path
+
try:
- file, path, desc = imp.find_module(name, toolpath)
try:
- module = imp.load_module(name, file, path, desc)
- spec = apply(ToolSpec, (name,), kw)
- spec.generate = module.generate
- spec.exists = module.exists
- return spec
- finally:
- if file:
- file.close()
- except ImportError, e:
- pass
+ file, path, desc = imp.find_module(name, toolpath)
+ try:
+ module = imp.load_module(name, file, path, desc)
+ spec = apply(ToolSpec, (name,), kw)
+ spec.generate = module.generate
+ spec.exists = module.exists
+ return spec
+ finally:
+ if file:
+ file.close()
+ except ImportError, e:
+ pass
+ finally:
+ sys.path = oldpythonpath
+
full_name = 'SCons.Tool.' + name
if not sys.modules.has_key(full_name):
test.subdir('tools')
+test.write(['tools', 'Common.py'], r"""\
+One = 1
+""")
+
test.write(['tools', 'SCCS.py'], r"""\
+import Common
def generate(env):
- env['TOOL_SCCS2'] = 1
+ env['TOOL_SCCS2'] = Common.One
def exists(env):
- return 1
+ return Common.One
""")
test.write(['tools', 'bar.py'], r"""\