# HG changeset patch # User cmlenz # Date 1216040536 0 # Node ID d21f92883d82ceee25342d23a7a3d6e4394e0b5b # Parent 47321cbc3ac19470d8acdb37bc04ed7fbedd28e5 More graceful `__version__` initialization when Babel is not installed in a way Setuptools knows about it. diff --git a/babel/__init__.py b/babel/__init__.py --- 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