diff options
author | PJ Eby <distutils-sig@python.org> | 2005-11-13 01:08:33 +0000 |
---|---|---|
committer | PJ Eby <distutils-sig@python.org> | 2005-11-13 01:08:33 +0000 |
commit | 483a7ec258edae5a8f5568bdd5c47421c48c2a22 (patch) | |
tree | 9bf3b3be77e9659c12cd287d44b4448c7120cf6a /pkg_resources.py | |
parent | f13f9923afdc0c7ed240029c32c0c80778989b43 (diff) | |
download | external_python_setuptools-483a7ec258edae5a8f5568bdd5c47421c48c2a22.tar.gz external_python_setuptools-483a7ec258edae5a8f5568bdd5c47421c48c2a22.tar.bz2 external_python_setuptools-483a7ec258edae5a8f5568bdd5c47421c48c2a22.zip |
Fixed a problem with nested namespace packages (e.g. ``peak.util``) not
being set as an attribute of their parent package.
--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041431
Diffstat (limited to 'pkg_resources.py')
-rw-r--r-- | pkg_resources.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/pkg_resources.py b/pkg_resources.py index 584e1bc6..eb4612a5 100644 --- a/pkg_resources.py +++ b/pkg_resources.py @@ -843,7 +843,7 @@ def safe_extra(extra): and the result is always lowercased. """ return re.sub('[^A-Za-z0-9]+', '_', extra).lower() - + @@ -1423,7 +1423,7 @@ def _handle_ns(packageName, path_item): module = sys.modules.get(packageName) if module is None: module = sys.modules[packageName] = new.module(packageName) - module.__path__ = [] + module.__path__ = []; _set_parent_ns(packageName) elif not hasattr(module,'__path__'): raise TypeError("Not a package:", packageName) handler = _find_adapter(_namespace_handlers, importer) @@ -1501,12 +1501,12 @@ def normalize_path(filename): return os.path.normcase(os.path.realpath(filename)) - - - - - - +def _set_parent_ns(packageName): + parts = packageName.split('.') + name = parts.pop() + if parts: + parent = '.'.join(parts) + setattr(sys.modules[parent], name, sys.modules[packageName]) @@ -1945,7 +1945,7 @@ class Distribution(object): g = globals() try: # find the first stack frame that is *not* code in - # the pkg_resources module, to use for the warning + # the pkg_resources module, to use for the warning while sys._getframe(level).f_globals is g: level += 1 except ValueError: |