diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2014-06-22 10:09:44 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2014-06-22 10:09:44 -0400 |
commit | 17d0ff6e1f9d2efb134cac3fc734c0cf5fa55f68 (patch) | |
tree | d0069cf8a69c09d2f2d930396bf98727e04053c2 /setuptools/command | |
parent | ab7d8ee3234b039d9dd3d6c896932b6985380327 (diff) | |
download | external_python_setuptools-17d0ff6e1f9d2efb134cac3fc734c0cf5fa55f68.tar.gz external_python_setuptools-17d0ff6e1f9d2efb134cac3fc734c0cf5fa55f68.tar.bz2 external_python_setuptools-17d0ff6e1f9d2efb134cac3fc734c0cf5fa55f68.zip |
Extract the additional trailing lines when a parent package is indicated.
Diffstat (limited to 'setuptools/command')
-rwxr-xr-x | setuptools/command/install_egg_info.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/setuptools/command/install_egg_info.py b/setuptools/command/install_egg_info.py index 3a8d5ec0..67ba7453 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -60,16 +60,21 @@ class install_egg_info(Command): unpack_archive(self.source, self.target, skimmer) - _nspkg_tmpl = [ + _nspkg_tmpl = ( "import sys, types, os", "p = os.path.join(sys._getframe(1).f_locals['sitedir'], *%(pth)r)", "ie = os.path.exists(os.path.join(p,'__init__.py'))", "m = not ie and sys.modules.setdefault(%(pkg)r, types.ModuleType(%(pkg)r))", "mp = (m or []) and m.__dict__.setdefault('__path__',[])", - "(p not in mp) and mp.append(p)%(trailer)s", - ] + "(p not in mp) and mp.append(p)", + ) "lines for the namespace installer" + _nspkg_tmpl_multi = ( + 'm and setattr(sys.modules[%(parent)r], %(child)r, m)', + ) + "additional line(s) when a parent package is indicated" + def install_namespaces(self): nsp = self._get_all_ns_packages() if not nsp: @@ -84,13 +89,11 @@ class install_egg_info(Command): # ensure pkg is not a unicode string under Python 2.7 pkg = str(pkg) pth = tuple(pkg.split('.')) - trailer = '\n' - if '.' in pkg: - trailer = ( - "; m and setattr(sys.modules[%r], %r, m)\n" - % ('.'.join(pth[:-1]), pth[-1]) - ) - dat = ';'.join(self._nspkg_tmpl) % locals() + tmpl_lines = self._nspkg_tmpl + parent, sep, child = pkg.rpartition('.') + if parent: + tmpl_lines += self._nspkg_tmpl_multi + dat = ';'.join(tmpl_lines) % locals() + '\n' f.write(dat) f.close() |