Commit 483a7ec2 authored by PJ Eby's avatar PJ Eby

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
parent f13f9923
...@@ -843,7 +843,7 @@ def safe_extra(extra): ...@@ -843,7 +843,7 @@ def safe_extra(extra):
and the result is always lowercased. and the result is always lowercased.
""" """
return re.sub('[^A-Za-z0-9]+', '_', extra).lower() return re.sub('[^A-Za-z0-9]+', '_', extra).lower()
...@@ -1423,7 +1423,7 @@ def _handle_ns(packageName, path_item): ...@@ -1423,7 +1423,7 @@ def _handle_ns(packageName, path_item):
module = sys.modules.get(packageName) module = sys.modules.get(packageName)
if module is None: if module is None:
module = sys.modules[packageName] = new.module(packageName) module = sys.modules[packageName] = new.module(packageName)
module.__path__ = [] module.__path__ = []; _set_parent_ns(packageName)
elif not hasattr(module,'__path__'): elif not hasattr(module,'__path__'):
raise TypeError("Not a package:", packageName) raise TypeError("Not a package:", packageName)
handler = _find_adapter(_namespace_handlers, importer) handler = _find_adapter(_namespace_handlers, importer)
...@@ -1501,12 +1501,12 @@ def normalize_path(filename): ...@@ -1501,12 +1501,12 @@ def normalize_path(filename):
return os.path.normcase(os.path.realpath(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): ...@@ -1945,7 +1945,7 @@ class Distribution(object):
g = globals() g = globals()
try: try:
# find the first stack frame that is *not* code in # 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: while sys._getframe(level).f_globals is g:
level += 1 level += 1
except ValueError: except ValueError:
......
...@@ -1500,6 +1500,9 @@ Release Notes/Change History ...@@ -1500,6 +1500,9 @@ Release Notes/Change History
* Fix path insertion algorithm for case-insensitive filesystems. * 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 0.6a6
* Activated distributions are now inserted in ``sys.path`` (and the working * Activated distributions are now inserted in ``sys.path`` (and the working
set) just before the directory that contains them, instead of at the end. set) just before the directory that contains them, instead of at the end.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment