diff options
| author | Steven Knight <knight@baldmt.com> | 2004-10-07 19:41:27 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2004-10-07 19:41:27 (GMT) |
| commit | ef5302e42b97cc6afabc1cb8390fe3d683dc5d81 (patch) | |
| tree | 66fbe2e9b51aa6d174c11fc80b98ced77b95ae15 /src/engine | |
| parent | 1a5adfd67ec02f9a2fdfa8a2da87dc7266759114 (diff) | |
| download | SCons-ef5302e42b97cc6afabc1cb8390fe3d683dc5d81.zip SCons-ef5302e42b97cc6afabc1cb8390fe3d683dc5d81.tar.gz SCons-ef5302e42b97cc6afabc1cb8390fe3d683dc5d81.tar.bz2 | |
Allow importing local files from Tools found on a toolpath. (Chad Austin)
Diffstat (limited to 'src/engine')
| -rw-r--r-- | src/engine/SCons/Tool/__init__.py | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 2adaacb..71ef082 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -69,19 +69,26 @@ class ToolSpec: 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): |
