From 606015e88f41070ffb182dfcc57926a858dd3358 Mon Sep 17 00:00:00 2001 From: Aurelien Bompard Date: Tue, 17 May 2011 08:12:10 +0200 Subject: Don't try to import the parent of a namespace package in declare_namespace -- fixes #204 --HG-- branch : distribute extra : rebase_source : 1644e937b2d0b2fae58e27740d0fddfe082586cd --- pkg_resources.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'pkg_resources.py') diff --git a/pkg_resources.py b/pkg_resources.py index 30dbc188..5eb19df3 100644 --- a/pkg_resources.py +++ b/pkg_resources.py @@ -1773,11 +1773,12 @@ def declare_namespace(packageName): if '.' in packageName: parent = '.'.join(packageName.split('.')[:-1]) declare_namespace(parent) - __import__(parent) - try: - path = sys.modules[parent].__path__ - except AttributeError: - raise TypeError("Not a package:", parent) + if parent not in _namespace_packages: + __import__(parent) + try: + path = sys.modules[parent].__path__ + except AttributeError: + raise TypeError("Not a package:", parent) # Track what packages are namespaces, so when new path items are added, # they can be updated -- cgit v1.2.1