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 | |
| parent | f13f9923afdc0c7ed240029c32c0c80778989b43 (diff) | |
| download | python-setuptools-git-483a7ec258edae5a8f5568bdd5c47421c48c2a22.tar.gz | |
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
| -rw-r--r-- | pkg_resources.py | 18 | ||||
| -rwxr-xr-x | pkg_resources.txt | 3 |
2 files changed, 12 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: diff --git a/pkg_resources.txt b/pkg_resources.txt index e62ed25f..3018dd8e 100755 --- a/pkg_resources.txt +++ b/pkg_resources.txt @@ -1500,6 +1500,9 @@ Release Notes/Change History * Fix path insertion algorithm for case-insensitive filesystems. + * Fixed a problem with nested namespace packages (e.g. ``peak.util``) not + being set as an attribute of their parent package. + 0.6a6 * Activated distributions are now inserted in ``sys.path`` (and the working set) just before the directory that contains them, instead of at the end. |
