# HG changeset patch # User Frederic Bastien # Date 1288125260 14400 # Node ID cf0fc12a50f7baa0211b49cb68384036e919ab14 # Parent 4ac393ec2eb7ac777af69a4e17c484bb17d13a03 record_version work with module that are not checkout and have __version__ defined(as numpy). diff -r 4ac393ec2eb7 -r cf0fc12a50f7 pylearn/version.py --- a/pylearn/version.py Fri Oct 22 11:11:51 2010 -0400 +++ b/pylearn/version.py Tue Oct 26 16:34:20 2010 -0400 @@ -216,6 +216,7 @@ 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 @@ -223,21 +224,26 @@ resource_type = location[2][2] if resource_type == _imp.PY_SOURCE: - return _import_id_py_source(location) + ret = _import_id_py_source(location) if resource_type == _imp.PY_COMPILED: - return _import_id_py_compiled(location) + ret = _import_id_py_compiled(location) if resource_type == _imp.C_EXTENSION: raise NotImplementedError if resource_type == _imp.PY_RESOURCE: raise NotImplementedError if resource_type == _imp.PKG_DIRECTORY: - return _import_id_pkg_directory(location) + ret = _import_id_pkg_directory(location) if resource_type == _imp.C_BUILTIN: raise NotImplementedError if resource_type == _imp.PY_FROZEN: raise NotImplementedError + #the list of resource types above should be exhaustive - assert False #the list of resource types above should be exhaustive + if ret.startswith(_unknown_version): + if hasattr(mod,'__version__'): + return mod.__version__ + else: + return ret def import_id(tag): """Return an identifier of the code imported by 'import '.