From ddfd78c6ab7f8abee2c8feef195e3db2d573ceaf Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 5 Jan 2007 19:39:39 +0000 Subject: Fix a problem installing eggs with a system packaging tool if the project contained an implicit namespace package; for example if the ``setup()`` listed a namespace package ``foo.bar`` without explicitly listing ``foo`` as a namespace package. (backport from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4053271 --- setuptools/command/install_egg_info.py | 51 ++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 5 deletions(-) (limited to 'setuptools/command/install_egg_info.py') diff --git a/setuptools/command/install_egg_info.py b/setuptools/command/install_egg_info.py index 4c79f41b..8f972638 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -22,7 +22,7 @@ class install_egg_info(Command): None, None, ei_cmd.egg_name, ei_cmd.egg_version ).egg_name()+'.egg-info' self.source = ei_cmd.egg_info - self.target = os.path.join(self.install_dir, basename) + self.target = os.path.join(self.install_dir, basename) self.outputs = [self.target] def run(self): @@ -43,7 +43,7 @@ class install_egg_info(Command): return self.outputs def copytree(self): - # Copy the .egg-info tree to site-packages + # Copy the .egg-info tree to site-packages def skimmer(src,dst): # filter out source-control directories; note that 'src' is always # a '/'-separated path, regardless of platform. 'dst' is a @@ -57,9 +57,8 @@ class install_egg_info(Command): unpack_archive(self.source, self.target, skimmer) def install_namespaces(self): - nsp = (self.distribution.namespace_packages or [])[:] + nsp = self._get_all_ns_packages() if not nsp: return - nsp.sort() # set up shorter names first filename,ext = os.path.splitext(self.target) filename += '-nspkg.pth'; self.outputs.append(filename) log.info("Installing %s",filename) @@ -78,5 +77,47 @@ class install_egg_info(Command): "(p not in mp) and mp.append(p)\n" % locals() ) - f.close() + f.close() + + + def _get_all_ns_packages(self): + nsp = {} + for pkg in self.distribution.namespace_packages or []: + pkg = pkg.split('.') + while pkg: + nsp['.'.join(pkg)] = 1 + pkg.pop() + nsp=list(nsp) + nsp.sort() # set up shorter names first + return nsp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.1