diff options
author | Steven Knight <knight@baldmt.com> | 2002-04-16 12:30:36 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2002-04-16 12:30:36 (GMT) |
commit | 42ed072377b5d6d3735abb0b3d0f61e7941879c7 (patch) | |
tree | 5f2005485f08072f7065bd24259461c1d87bf186 /src/engine/SCons/Script | |
parent | 0331e6f13472a35aedb7e61db4ab8219e464bed2 (diff) | |
download | SCons-42ed072377b5d6d3735abb0b3d0f61e7941879c7.zip SCons-42ed072377b5d6d3735abb0b3d0f61e7941879c7.tar.gz SCons-42ed072377b5d6d3735abb0b3d0f61e7941879c7.tar.bz2 |
Fix importing of modules from the SConscript directory (Anthony Roach)
Diffstat (limited to 'src/engine/SCons/Script')
-rw-r--r-- | src/engine/SCons/Script/SConscript.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index eb1a13e..f30652d 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -39,6 +39,7 @@ import SCons.Node.FS import SCons.Util import os +import os.path import string import sys @@ -105,8 +106,8 @@ def SConscript(script, exports=[]): # push: stack.append(Frame(exports)) - old_dir = None + old_sys_path = sys.path try: # call: if script == "-": @@ -120,11 +121,18 @@ def SConscript(script, exports=[]): if sconscript_chdir: old_dir = os.getcwd() os.chdir(str(script.dir)) + + # prepend the SConscript directory to sys.path so + # that Python modules in the SConscript directory can + # be easily imported. + sys.path = [os.path.abspath(str(script.dir))] + sys.path + exec file in stack[-1].globals else: sys.stderr.write("Ignoring missing SConscript '%s'\n" % script.path) finally: # pop: + sys.path = old_sys_path frame = stack.pop() SCons.Node.FS.default_fs.chdir(frame.prev_dir) if old_dir: |