Boost logo

Boost-Commit :

From: juergen.hunold_at_[hidden]
Date: 2008-08-10 14:25:51


Author: jhunold
Date: 2008-08-10 14:25:50 EDT (Sun, 10 Aug 2008)
New Revision: 48064
URL: http://svn.boost.org/trac/boost/changeset/48064

Log:
Fix import rule.
First try to find an already loaded module, then try import one via Python.
Fixes usage of "feature.set_default", because "feature" acts like a singleton.

Text files modified:
   branches/build/python_port/python/boost/build/build/project.py | 13 +++++++++++--
   1 files changed, 11 insertions(+), 2 deletions(-)

Modified: branches/build/python_port/python/boost/build/build/project.py
==============================================================================
--- branches/build/python_port/python/boost/build/build/project.py (original)
+++ branches/build/python_port/python/boost/build/build/project.py 2008-08-10 14:25:50 EDT (Sun, 10 Aug 2008)
@@ -573,8 +573,10 @@
         return result
 
     def load_module(self, name, extra_path=None):
- """Find a Python module called 'name' in Boost.Build search
- path and load it. The module is not entered in sys.modules.
+ """Classic Boost.Build 'modules' are in fact global variables.
+ Therefore, try to find an already loaded Python module called 'name' in sys.modules.
+ If the module ist not loaded, find it Boost.Build search
+ path and load it. The new module is not entered in sys.modules.
         The motivation here is to have disjoint namespace of modules
         loaded via 'import/using' in Jamfile, and ordinary Python
         modules. We don't want 'using foo' in Jamfile to load ordinary
@@ -586,6 +588,13 @@
         existing = self.loaded_tool_modules_.get(name)
         if existing:
             return existing
+
+ modules = sys.modules
+ for class_name in modules:
+ if name in class_name:
+ module = modules[class_name]
+ self.loaded_tool_modules_[name] = module
+ return module
         
         path = extra_path
         if not path:


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk