diff -r 1b1f8f32fe86 -r 33a3a5f7c2ea src/SConscript --- a/src/SConscript Thu Jun 24 15:34:21 2010 -0400 +++ b/src/SConscript Mon Jul 05 17:25:01 2010 -0700 @@ -133,14 +133,18 @@ arcpath = path + [ self.basename ] abspath = self.snode.abspath - if not exists(abspath): + if exists(abspath): + srcpath = self.snode.path + else: abspath = self.tnode.abspath + srcpath = None self.package = package self.modname = modname self.modpath = modpath self.arcname = joinpath(*arcpath) self.abspath = abspath + self.srcpath = srcpath self.compiled = File(self.filename + 'c') self.assembly = File(self.filename + '.s') self.symname = "PyEMB_" + PySource.invalid_sym_char.sub('_', modpath) @@ -929,12 +933,18 @@ dst = file(str(target[0]), 'w') def dump_mod(sym, endchar=','): + def c_str(string): + if string is None: + return "0" + return '"%s"' % string pysource = PySource.symnames[sym] - print >>dst, ' { "%s",' % pysource.arcname - print >>dst, ' "%s",' % pysource.modpath - print >>dst, ' %s_beg, %s_end,' % (sym, sym) - print >>dst, ' %s_end - %s_beg,' % (sym, sym) - print >>dst, ' *(int *)%s_end }%s' % (sym, endchar) + print >>dst, ' { %s,' % c_str(pysource.arcname) + print >>dst, ' %s,' % c_str(pysource.abspath) + print >>dst, ' %s,' % c_str(pysource.srcpath) + print >>dst, ' %s,' % c_str(pysource.modpath) + print >>dst, ' %s_beg, %s_end,' % (sym, sym) + print >>dst, ' %s_end - %s_beg,' % (sym, sym) + print >>dst, ' *(int *)%s_end }%s' % (sym, endchar) print >>dst, '#include "sim/init.hh"' @@ -953,7 +963,7 @@ # Skip the importer since we've already exported it continue dump_mod(sym) - print >>dst, " { 0, 0, 0, 0, 0, 0 }" + print >>dst, " { 0, 0, 0, 0, 0, 0, 0, 0 }" print >>dst, "};" diff -r 1b1f8f32fe86 -r 33a3a5f7c2ea src/python/importer.py --- a/src/python/importer.py Thu Jun 24 15:34:21 2010 -0400 +++ b/src/python/importer.py Mon Jul 05 17:25:01 2010 -0700 @@ -33,11 +33,11 @@ def __init__(self): self.modules = {} - def add_module(self, filename, modpath, code): + def add_module(self, filename, abspath, srcpath, modpath, code): if modpath in self.modules: raise AttributeError, "%s already found in importer" - self.modules[modpath] = (filename, code) + self.modules[modpath] = (filename, abspath, srcpath, code) def find_module(self, fullname, path): if fullname in self.modules: @@ -59,7 +59,13 @@ try: mod.__loader__ = self - srcfile,code = self.modules[fullname] + srcfile,abspath,srcpath,code = self.modules[fullname] + + override = os.environ.get('M5_OVERRIDE', 'false').lower() + if override in ('true', 'yes') and os.path.exists(abspath): + src = file(abspath, 'r').read() + code = compile(src, abspath, 'exec') + if os.path.basename(srcfile) == '__init__.py': mod.__path__ = fullname.split('.') mod.__file__ = srcfile diff -r 1b1f8f32fe86 -r 33a3a5f7c2ea src/sim/init.hh --- a/src/sim/init.hh Thu Jun 24 15:34:21 2010 -0400 +++ b/src/sim/init.hh Mon Jul 05 17:25:01 2010 -0700 @@ -37,6 +37,8 @@ struct EmbeddedPyModule { const char *filename; + const char *abspath; + const char *srcpath; const char *modpath; const char *code; const char *code_end; diff -r 1b1f8f32fe86 -r 33a3a5f7c2ea src/sim/init.cc --- a/src/sim/init.cc Thu Jun 24 15:34:21 2010 -0400 +++ b/src/sim/init.cc Mon Jul 05 17:25:01 2010 -0700 @@ -154,7 +154,8 @@ while (pymod->filename) { PyObject *code = getCode(pymod); PyObject *result = PyObject_CallMethod(module, PyCC("add_module"), - PyCC("ssO"), pymod->filename, pymod->modpath, code); + PyCC("ssssO"), pymod->filename, pymod->abspath, pymod->srcpath, + pymod->modpath, code); if (!result) { PyErr_Print(); return 1;