summaryrefslogtreecommitdiff
path: root/src/python/importer.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/importer.py')
-rw-r--r--src/python/importer.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/python/importer.py b/src/python/importer.py
index fe099fdb8..4e364873f 100644
--- a/src/python/importer.py
+++ b/src/python/importer.py
@@ -33,11 +33,11 @@ class CodeImporter(object):
def __init__(self):
self.modules = {}
- def add_module(self, filename, modpath, code):
+ def add_module(self, filename, abspath, modpath, code):
if modpath in self.modules:
raise AttributeError, "%s already found in importer"
- self.modules[modpath] = (filename, code)
+ self.modules[modpath] = (filename, abspath, code)
def find_module(self, fullname, path):
if fullname in self.modules:
@@ -59,7 +59,13 @@ class CodeImporter(object):
try:
mod.__loader__ = self
- srcfile,code = self.modules[fullname]
+ srcfile,abspath,code = self.modules[fullname]
+
+ override = os.environ.get('M5_OVERRIDE_PY_SOURCE', '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