# HG changeset patch # User Frederic Bastien # Date 1288190215 14400 # Node ID 6bae1852cff441fd8d4a578f3adf9415ba9418f7 # Parent 2b8b991ac5fa23ada7e6efcb90e744a765ea12bb make version detection work around a strange behavior of imp.find_module diff -r 2b8b991ac5fa -r 6bae1852cff4 pylearn/version.py --- a/pylearn/version.py Wed Oct 27 10:33:16 2010 -0400 +++ b/pylearn/version.py Wed Oct 27 10:36:55 2010 -0400 @@ -215,11 +215,17 @@ def _import_id(tag): try : - location = _imp.find_module(tag) mod = __import__(tag) except ImportError, e: #raise when tag is not found return e #put this in the cache, import_id will raise it - + + try: + location = _imp.find_module(tag) + except ImportError, e: #raise when tag is not found + #sometimes fin_module raise an ImportError even when we can import it + if hasattr(mod,'__version__'): + return mod.__version__ + return e #the find_module was successful, location is valid resource_type = location[2][2]