Mercurial > pylearn
changeset 1343:cf0fc12a50f7
record_version work with module that are not checkout and have __version__ defined(as numpy).
author | Frederic Bastien <nouiz@nouiz.org> |
---|---|
date | Tue, 26 Oct 2010 16:34:20 -0400 |
parents | 4ac393ec2eb7 |
children | 2b8b991ac5fa |
files | pylearn/version.py |
diffstat | 1 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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 <tag>'.