changeset 390:d21f92883d82

More graceful `__version__` initialization when Babel is not installed in a way Setuptools knows about it.
author cmlenz
date Mon, 14 Jul 2008 13:02:16 +0000
parents 47321cbc3ac1
children 34c0a25b1ed7
files babel/__init__.py
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/babel/__init__.py
+++ b/babel/__init__.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2007 Edgewall Software
+# Copyright (C) 2007-2008 Edgewall Software
 # All rights reserved.
 #
 # This software is licensed as described in the file COPYING, which
@@ -30,6 +30,10 @@
 
 __docformat__ = 'restructuredtext en'
 try:
-    __version__ = __import__('pkg_resources').get_distribution('Babel').version
+    from pkg_resources import get_distribution, ResolutionError
+    try:
+        __version__ = get_distribution('Babel').version
+    except ResolutionError:
+        __version__ = None # unknown
 except ImportError:
-    pass
+    __version__ = None # unknown
Copyright (C) 2012-2017 Edgewall Software