[Python-checkins] r57946 - in sandbox/branches/setuptools-0.6: setuptools.txt setuptools/command/install_egg_info.py

phillip.eby python-checkins at python.org
Tue Sep 4 06:10:16 CEST 2007


Author: phillip.eby
Date: Tue Sep  4 06:10:16 2007
New Revision: 57946

Modified:
   sandbox/branches/setuptools-0.6/setuptools.txt
   sandbox/branches/setuptools-0.6/setuptools/command/install_egg_info.py
Log:
Fix import problems with nested namespace packages installed via
``--root`` or ``--single-version-externally-managed``, due to the
parent package not having the child package as an attribute.
(backport from trunk)


Modified: sandbox/branches/setuptools-0.6/setuptools.txt
==============================================================================
--- sandbox/branches/setuptools-0.6/setuptools.txt	(original)
+++ sandbox/branches/setuptools-0.6/setuptools.txt	Tue Sep  4 06:10:16 2007
@@ -2616,6 +2616,10 @@
  * Fixed ``distutils.filelist.findall()`` crashing on broken symlinks, and 
    ``egg_info`` command failing on new, uncommitted SVN directories.
 
+ * Fix import problems with nested namespace packages installed via
+   ``--root`` or ``--single-version-externally-managed``, due to the
+   parent package not having the child package as an attribute.
+
 0.6c6
  * Added ``--egg-path`` option to ``develop`` command, allowing you to force
    ``.egg-link`` files to use relative paths (allowing them to be shared across

Modified: sandbox/branches/setuptools-0.6/setuptools/command/install_egg_info.py
==============================================================================
--- sandbox/branches/setuptools-0.6/setuptools/command/install_egg_info.py	(original)
+++ sandbox/branches/setuptools-0.6/setuptools/command/install_egg_info.py	Tue Sep  4 06:10:16 2007
@@ -56,6 +56,30 @@
             return dst
         unpack_archive(self.source, self.target, skimmer)
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
     def install_namespaces(self):
         nsp = self._get_all_ns_packages()
         if not nsp: return
@@ -66,6 +90,12 @@
             f = open(filename,'wb')
             for pkg in nsp:
                 pth = tuple(pkg.split('.'))
+                trailer = '\n'
+                if '.' in pkg:
+                    trailer = (
+                        "; m and setattr(sys.modules[%r], %r, m)\n"
+                        % ('.'.join(pth[:-1]), pth[-1])
+                    )
                 f.write(
                     "import sys,new,os; "
                     "p = os.path.join(sys._getframe(1).f_locals['sitedir'], "
@@ -74,12 +104,11 @@
                     "m = not ie and "
                         "sys.modules.setdefault(%(pkg)r,new.module(%(pkg)r)); "
                     "mp = (m or []) and m.__dict__.setdefault('__path__',[]); "
-                    "(p not in mp) and mp.append(p)\n"
+                    "(p not in mp) and mp.append(p)%(trailer)s"
                     % locals()
                 )
             f.close()
 
-
     def _get_all_ns_packages(self):
         nsp = {}
         for pkg in self.distribution.namespace_packages or []:
@@ -92,32 +121,3 @@
         return nsp
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-


More information about the Python-checkins mailing list