aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/command/install_egg_info.py
diff options
context:
space:
mode:
authorPJ Eby <distutils-sig@python.org>2006-03-17 16:57:23 +0000
committerPJ Eby <distutils-sig@python.org>2006-03-17 16:57:23 +0000
commit92a61578a4b7d09ad6a6f9524163e67b62782e18 (patch)
tree7d6a363dca53ef9f97f625100e9ce1006eb107b7 /setuptools/command/install_egg_info.py
parent0b0d41cde67414ab19b030ea48b497e17134be19 (diff)
downloadexternal_python_setuptools-92a61578a4b7d09ad6a6f9524163e67b62782e18.tar.gz
external_python_setuptools-92a61578a4b7d09ad6a6f9524163e67b62782e18.tar.bz2
external_python_setuptools-92a61578a4b7d09ad6a6f9524163e67b62782e18.zip
Support namespace packages in conjunction with system packagers, by omitting
the installation of any ``__init__.py`` files for namespace packages, and adding a special ``.pth`` file to create a working package in ``sys.modules``. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4043119
Diffstat (limited to 'setuptools/command/install_egg_info.py')
-rwxr-xr-xsetuptools/command/install_egg_info.py44
1 files changed, 22 insertions, 22 deletions
diff --git a/setuptools/command/install_egg_info.py b/setuptools/command/install_egg_info.py
index 0b61a11d..a537b5e7 100755
--- a/setuptools/command/install_egg_info.py
+++ b/setuptools/command/install_egg_info.py
@@ -37,7 +37,7 @@ class install_egg_info(Command):
self.execute(self.copytree, (),
"Copying %s to %s" % (self.source, self.target)
)
-
+ self.install_namespaces()
def get_outputs(self):
return self.outputs
@@ -58,25 +58,25 @@ class install_egg_info(Command):
unpack_archive(self.source, self.target, skimmer)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ def install_namespaces(self):
+ nsp = (self.distribution.namespace_packages or [])[:]
+ 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)
+ if not self.dry_run:
+ f = open(filename,'wb')
+ for pkg in nsp:
+ pth = tuple(pkg.split('.'))
+ f.write(
+ "import sys,new; "
+ "m = sys.modules.setdefault(%(pkg)r,new.module(%(pkg)r)); "
+ "p = os.path.join(sys._getframe(1).f_locals['sitedir'], "
+ "*%(pth)r); "
+ "mp = m.__path__ = getattr(m,'__path__',[]); "
+ "(p not in mp) and mp.append(p)\n"
+ % locals()
+ )
+ f.close()