diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2014-06-22 09:37:30 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2014-06-22 09:37:30 -0400 |
commit | ab7d8ee3234b039d9dd3d6c896932b6985380327 (patch) | |
tree | 8eaea668b16d28d560c5a3161492737c89bcf717 /setuptools/command/install_egg_info.py | |
parent | e7a30ebf78b0d9aaea9cfeadd36df2ba9774c25c (diff) | |
download | external_python_setuptools-ab7d8ee3234b039d9dd3d6c896932b6985380327.tar.gz external_python_setuptools-ab7d8ee3234b039d9dd3d6c896932b6985380327.tar.bz2 external_python_setuptools-ab7d8ee3234b039d9dd3d6c896932b6985380327.zip |
Extract the lines of the namespace package pth file template for readability.
Diffstat (limited to 'setuptools/command/install_egg_info.py')
-rwxr-xr-x | setuptools/command/install_egg_info.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/setuptools/command/install_egg_info.py b/setuptools/command/install_egg_info.py index 06be25f3..3a8d5ec0 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -60,6 +60,16 @@ class install_egg_info(Command): unpack_archive(self.source, self.target, skimmer) + _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", + ] + "lines for the namespace installer" + def install_namespaces(self): nsp = self._get_all_ns_packages() if not nsp: @@ -80,18 +90,8 @@ class install_egg_info(Command): "; m and setattr(sys.modules[%r], %r, m)\n" % ('.'.join(pth[:-1]), pth[-1]) ) - f.write( - "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" - % locals() - ) + dat = ';'.join(self._nspkg_tmpl) % locals() + f.write(dat) f.close() def _get_all_ns_packages(self): |