From c7eeb6273fd7593d7bccfbe41f44b5aa2ab17c1d Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Wed, 14 Dec 2005 17:37:30 +0000 Subject: Added an internal ``install_egg_info`` command to use as part of old-style ``install`` operations, that installs an ``.egg-info`` directory with the package. This is a preliminary step to implementing "install --single-version-externally-managed" for use with bdist_* commands and Debian. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041670 --- setuptools/command/install_egg_info.py | 82 ++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 setuptools/command/install_egg_info.py (limited to 'setuptools/command/install_egg_info.py') diff --git a/setuptools/command/install_egg_info.py b/setuptools/command/install_egg_info.py new file mode 100755 index 00000000..14f9755f --- /dev/null +++ b/setuptools/command/install_egg_info.py @@ -0,0 +1,82 @@ +from setuptools import Command +from setuptools.archive_util import unpack_archive +from distutils import log, dir_util +import os, shutil, pkg_resources + +class install_egg_info(Command): + """Install an .egg-info directory for the package""" + + description = "Install an .egg-info directory for the package" + + user_options = [ + ('install-dir=', 'd', "directory to install to"), + ] + + def initialize_options(self): + self.install_dir = None + + def finalize_options(self): + self.set_undefined_options('install_lib',('install_dir','install_dir')) + ei_cmd = self.get_finalized_command("egg_info") + basename = pkg_resources.Distribution( + 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) + + def run(self): + self.run_command('egg_info') + target = self.target + if os.path.isdir(self.target) and not os.path.islink(self.target): + dir_util.remove_tree(self.target, dry_run=self.dry_run) + elif os.path.exists(self.target): + self.execute(os.unlink,(self.target,),"Removing "+self.target) + if not self.dry_run: + pkg_resources.ensure_directory(self.target) + self.execute(self.copytree, (), + "Copying %s to %s" % (self.source, self.target) + ) + + + + def get_outputs(self): + return [self.target] # XXX list all files, not just dir? + + def copytree(self): + # 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 + # platform-specific path. + for skip in '.svn/','CVS/': + if src.startswith(skip) or '/'+skip in src: + return None + log.debug("Copying %s to %s", src, dst) + return dst + + unpack_archive(self.source, self.target, skimmer) + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.1 From 19cad08e9f93dc0544226989944839f536cac1ff Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Thu, 15 Dec 2005 18:11:12 +0000 Subject: Make install_egg_info track every file it installs, not just the directory it installs to. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041699 --- setuptools/command/install_egg_info.py | 6 +++--- 1 file changed, 3 insertions(+), 3 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 14f9755f..0b61a11d 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -23,6 +23,7 @@ class install_egg_info(Command): ).egg_name()+'.egg-info' self.source = ei_cmd.egg_info self.target = os.path.join(self.install_dir, basename) + self.outputs = [self.target] def run(self): self.run_command('egg_info') @@ -38,9 +39,8 @@ class install_egg_info(Command): ) - def get_outputs(self): - return [self.target] # XXX list all files, not just dir? + return self.outputs def copytree(self): # Copy the .egg-info tree to site-packages @@ -52,6 +52,7 @@ class install_egg_info(Command): for skip in '.svn/','CVS/': if src.startswith(skip) or '/'+skip in src: return None + self.outputs.append(dst) log.debug("Copying %s to %s", src, dst) return dst @@ -75,7 +76,6 @@ class install_egg_info(Command): - -- cgit v1.2.1 From 92a61578a4b7d09ad6a6f9524163e67b62782e18 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 17 Mar 2006 16:57:23 +0000 Subject: 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 --- setuptools/command/install_egg_info.py | 44 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 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 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() -- cgit v1.2.1 From 5393f13525c33abcde2893fc0793a9db0aa03373 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 17 Mar 2006 17:16:19 +0000 Subject: Tweak the nspkg.pth hack to avoid creating a module if there *is* an __init__.py installed. It may be that this should check for .pyc/.pyo, but system packagers don't normally remove them. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4043120 --- setuptools/command/install_egg_info.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 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 a537b5e7..4c79f41b 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -43,8 +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 @@ -55,7 +54,6 @@ class install_egg_info(Command): self.outputs.append(dst) log.debug("Copying %s to %s", src, dst) return dst - unpack_archive(self.source, self.target, skimmer) def install_namespaces(self): @@ -70,11 +68,13 @@ class install_egg_info(Command): for pkg in nsp: pth = tuple(pkg.split('.')) f.write( - "import sys,new; " - "m = sys.modules.setdefault(%(pkg)r,new.module(%(pkg)r)); " + "import sys,new,os; " "p = os.path.join(sys._getframe(1).f_locals['sitedir'], " - "*%(pth)r); " - "mp = m.__path__ = getattr(m,'__path__',[]); " + "*%(pth)r); " + "ie = os.path.exists(os.path.join(p,'__init__.py')); " + "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" % locals() ) -- cgit v1.2.1 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 From 46c6ed5eb81ac806fb4e36c4dbfeb8146a07736d Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Tue, 4 Sep 2007 04:10:16 +0000 Subject: 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) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4057946 --- setuptools/command/install_egg_info.py | 62 +++++++++++++++++----------------- 1 file changed, 31 insertions(+), 31 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 8f972638..939340c5 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -56,6 +56,30 @@ class install_egg_info(Command): 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 @@ class install_egg_info(Command): 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 @@ class install_egg_info(Command): "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 @@ class install_egg_info(Command): return nsp - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.1 From 7ee68f0c5fe9122442c3f44aa94ebd1dfcc7b47e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Fri, 11 Sep 2009 23:23:25 +0200 Subject: Use types.ModuleType instead of new.module. --HG-- branch : distribute extra : rebase_source : 3327441a867ad2878553ed1d42418a7e68ee3067 --- setuptools/command/install_egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 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 939340c5..00c81221 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -97,12 +97,12 @@ class install_egg_info(Command): % ('.'.join(pth[:-1]), pth[-1]) ) f.write( - "import sys,new,os; " + "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,new.module(%(pkg)r)); " + "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() -- cgit v1.2.1 From 4d3db0dfec6a8abe6a78b20fb311dda6228fd43f Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Tue, 22 Sep 2009 17:42:15 +0200 Subject: Wrong file mode when creating bdists under Python 3.1. --HG-- branch : distribute extra : rebase_source : 3af8cc2ab10edeeeb75b03e1a63e8de008142176 --- setuptools/command/install_egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 00c81221..dd95552e 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -87,7 +87,7 @@ class install_egg_info(Command): filename += '-nspkg.pth'; self.outputs.append(filename) log.info("Installing %s",filename) if not self.dry_run: - f = open(filename,'wb') + f = open(filename,'wt') for pkg in nsp: pth = tuple(pkg.split('.')) trailer = '\n' -- cgit v1.2.1 From d7907a5c969ad05970e458cc7b69b522dda46164 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 6 Feb 2012 22:34:53 -0500 Subject: Fix #272 - TypeError when namespace_package is unicode --HG-- branch : distribute extra : rebase_source : 5bb6bc394dbe2834977b853af85241ae0a472de6 --- setuptools/command/install_egg_info.py | 2 ++ 1 file changed, 2 insertions(+) (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 dd95552e..f44b34b5 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -89,6 +89,8 @@ class install_egg_info(Command): if not self.dry_run: f = open(filename,'wt') for pkg in nsp: + # ensure pkg is not a unicode string under Python 2.7 + pkg = str(pkg) pth = tuple(pkg.split('.')) trailer = '\n' if '.' in pkg: -- cgit v1.2.1 From 657501ddc8410495c9f44b7280f4a7abf3241753 Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Sat, 15 Feb 2014 22:54:03 +0100 Subject: Clean some imports. --- setuptools/command/install_egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 f44b34b5..73b5ef73 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -1,7 +1,7 @@ from setuptools import Command from setuptools.archive_util import unpack_archive from distutils import log, dir_util -import os, shutil, pkg_resources +import os, pkg_resources class install_egg_info(Command): """Install an .egg-info directory for the package""" -- cgit v1.2.1 From 8e3f9d3253d1d0fb820dad4249d5110d017595c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Wed, 18 Jun 2014 20:31:05 +0300 Subject: Fixed PEP 8 compliancy of the setuptools.command package --- setuptools/command/install_egg_info.py | 70 +++++++++++++--------------------- 1 file changed, 26 insertions(+), 44 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 73b5ef73..a71268ab 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -1,7 +1,10 @@ +from distutils import log, dir_util +import os + from setuptools import Command from setuptools.archive_util import unpack_archive -from distutils import log, dir_util -import os, pkg_resources +import pkg_resources + class install_egg_info(Command): """Install an .egg-info directory for the package""" @@ -16,11 +19,12 @@ class install_egg_info(Command): self.install_dir = None def finalize_options(self): - self.set_undefined_options('install_lib',('install_dir','install_dir')) + self.set_undefined_options('install_lib', + ('install_dir', 'install_dir')) ei_cmd = self.get_finalized_command("egg_info") basename = pkg_resources.Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version - ).egg_name()+'.egg-info' + ).egg_name() + '.egg-info' self.source = ei_cmd.egg_info self.target = os.path.join(self.install_dir, basename) self.outputs = [self.target] @@ -31,11 +35,11 @@ class install_egg_info(Command): if os.path.isdir(self.target) and not os.path.islink(self.target): dir_util.remove_tree(self.target, dry_run=self.dry_run) elif os.path.exists(self.target): - self.execute(os.unlink,(self.target,),"Removing "+self.target) + self.execute(os.unlink, (self.target,), "Removing " + self.target) if not self.dry_run: pkg_resources.ensure_directory(self.target) - self.execute(self.copytree, (), - "Copying %s to %s" % (self.source, self.target) + self.execute( + self.copytree, (), "Copying %s to %s" % (self.source, self.target) ) self.install_namespaces() @@ -44,50 +48,29 @@ class install_egg_info(Command): def copytree(self): # Copy the .egg-info tree to site-packages - def skimmer(src,dst): + def skimmer(src, dst): # filter out source-control directories; note that 'src' is always # a '/'-separated path, regardless of platform. 'dst' is a # platform-specific path. - for skip in '.svn/','CVS/': - if src.startswith(skip) or '/'+skip in src: + for skip in '.svn/', 'CVS/': + if src.startswith(skip) or '/' + skip in src: return None self.outputs.append(dst) log.debug("Copying %s to %s", src, dst) return dst - unpack_archive(self.source, self.target, skimmer) - - - - - - - - - - - - - - - - - - - - - - - + unpack_archive(self.source, self.target, skimmer) def install_namespaces(self): nsp = self._get_all_ns_packages() - if not nsp: return - filename,ext = os.path.splitext(self.target) - filename += '-nspkg.pth'; self.outputs.append(filename) - log.info("Installing %s",filename) + if not nsp: + return + 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,'wt') + f = open(filename, 'wt') for pkg in nsp: # ensure pkg is not a unicode string under Python 2.7 pkg = str(pkg) @@ -101,10 +84,11 @@ class install_egg_info(Command): f.write( "import sys,types,os; " "p = os.path.join(sys._getframe(1).f_locals['sitedir'], " - "*%(pth)r); " + "*%(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)); " + "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() @@ -118,8 +102,6 @@ class install_egg_info(Command): while pkg: nsp['.'.join(pkg)] = 1 pkg.pop() - nsp=list(nsp) + nsp = list(nsp) nsp.sort() # set up shorter names first return nsp - - -- cgit v1.2.1 From 92683cba709e8ee497e2b8f4413d44ddcee5cc2f Mon Sep 17 00:00:00 2001 From: Matthew Iversen Date: Sun, 22 Jun 2014 21:48:22 +1000 Subject: Fix pep8 issues for install_egg_info --- setuptools/command/install_egg_info.py | 65 ++++++++++++---------------------- 1 file changed, 23 insertions(+), 42 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 73b5ef73..411fce6b 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -1,7 +1,10 @@ +import os + +import pkg_resources from setuptools import Command from setuptools.archive_util import unpack_archive from distutils import log, dir_util -import os, pkg_resources + class install_egg_info(Command): """Install an .egg-info directory for the package""" @@ -16,7 +19,8 @@ class install_egg_info(Command): self.install_dir = None def finalize_options(self): - self.set_undefined_options('install_lib',('install_dir','install_dir')) + self.set_undefined_options('install_lib', + ('install_dir', 'install_dir')) ei_cmd = self.get_finalized_command("egg_info") basename = pkg_resources.Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version @@ -27,14 +31,14 @@ class install_egg_info(Command): def run(self): self.run_command('egg_info') - target = self.target if os.path.isdir(self.target) and not os.path.islink(self.target): dir_util.remove_tree(self.target, dry_run=self.dry_run) elif os.path.exists(self.target): - self.execute(os.unlink,(self.target,),"Removing "+self.target) + self.execute(os.unlink, (self.target, ), "Removing " + self.target) if not self.dry_run: pkg_resources.ensure_directory(self.target) - self.execute(self.copytree, (), + self.execute( + self.copytree, (), "Copying %s to %s" % (self.source, self.target) ) self.install_namespaces() @@ -44,50 +48,28 @@ class install_egg_info(Command): def copytree(self): # Copy the .egg-info tree to site-packages - def skimmer(src,dst): + def skimmer(src, dst): # filter out source-control directories; note that 'src' is always # a '/'-separated path, regardless of platform. 'dst' is a # platform-specific path. - for skip in '.svn/','CVS/': - if src.startswith(skip) or '/'+skip in src: + for skip in '.svn/', 'CVS/': + if src.startswith(skip) or '/' + skip in src: return None self.outputs.append(dst) log.debug("Copying %s to %s", src, dst) return dst unpack_archive(self.source, self.target, skimmer) - - - - - - - - - - - - - - - - - - - - - - - - def install_namespaces(self): nsp = self._get_all_ns_packages() - if not nsp: return - filename,ext = os.path.splitext(self.target) - filename += '-nspkg.pth'; self.outputs.append(filename) - log.info("Installing %s",filename) + if not nsp: + return + 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,'wt') + f = open(filename, 'wt') for pkg in nsp: # ensure pkg is not a unicode string under Python 2.7 pkg = str(pkg) @@ -101,10 +83,11 @@ class install_egg_info(Command): f.write( "import sys,types,os; " "p = os.path.join(sys._getframe(1).f_locals['sitedir'], " - "*%(pth)r); " + "*%(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)); " + "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() @@ -118,8 +101,6 @@ class install_egg_info(Command): while pkg: nsp['.'.join(pkg)] = 1 pkg.pop() - nsp=list(nsp) + nsp = list(nsp) nsp.sort() # set up shorter names first return nsp - - -- cgit v1.2.1 From 9ec3bbc7bcef27123270535c1a3ab7cc9adda95d Mon Sep 17 00:00:00 2001 From: Matthew Iversen Date: Sun, 22 Jun 2014 22:01:17 +1000 Subject: Clean up _get_all_ns_packages --- setuptools/command/install_egg_info.py | 9 ++++----- 1 file changed, 4 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 411fce6b..578aa3d4 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -95,12 +95,11 @@ class install_egg_info(Command): f.close() def _get_all_ns_packages(self): - nsp = {} + """Return sorted list of all package namespaces""" + nsp = set() for pkg in self.distribution.namespace_packages or []: pkg = pkg.split('.') while pkg: - nsp['.'.join(pkg)] = 1 + nsp.add('.'.join(pkg)) pkg.pop() - nsp = list(nsp) - nsp.sort() # set up shorter names first - return nsp + return sorted(nsp) -- cgit v1.2.1 From e7a30ebf78b0d9aaea9cfeadd36df2ba9774c25c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 22 Jun 2014 09:25:16 -0400 Subject: Remove trailing newline --- setuptools/command/install_egg_info.py | 1 - 1 file changed, 1 deletion(-) (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 183d8188..06be25f3 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -103,4 +103,3 @@ class install_egg_info(Command): nsp.add('.'.join(pkg)) pkg.pop() return sorted(nsp) - -- cgit v1.2.1 From ab7d8ee3234b039d9dd3d6c896932b6985380327 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 22 Jun 2014 09:37:30 -0400 Subject: Extract the lines of the namespace package pth file template for readability. --- setuptools/command/install_egg_info.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 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 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): -- cgit v1.2.1 From 17d0ff6e1f9d2efb134cac3fc734c0cf5fa55f68 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 22 Jun 2014 10:09:44 -0400 Subject: Extract the additional trailing lines when a parent package is indicated. --- setuptools/command/install_egg_info.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 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 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() -- cgit v1.2.1 From 24978070e68c58dfd787b93d6f1e0a35f6871c52 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 22 Jun 2014 10:10:54 -0400 Subject: Use short-circuit for less nesting --- setuptools/command/install_egg_info.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 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 67ba7453..6aba68be 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -83,19 +83,21 @@ class install_egg_info(Command): filename += '-nspkg.pth' self.outputs.append(filename) log.info("Installing %s", filename) - if not self.dry_run: - f = open(filename, 'wt') - for pkg in nsp: - # ensure pkg is not a unicode string under Python 2.7 - pkg = str(pkg) - pth = tuple(pkg.split('.')) - 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() + if self.dry_run: + return + + f = open(filename, 'wt') + for pkg in nsp: + # ensure pkg is not a unicode string under Python 2.7 + pkg = str(pkg) + pth = tuple(pkg.split('.')) + 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() def _get_all_ns_packages(self): """Return sorted list of all package namespaces""" -- cgit v1.2.1 From 9f48d842e5c7c916f472420c7bc9f62b333a40ff Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 22 Jun 2014 10:13:38 -0400 Subject: Use context manager for opening and closing the file --- setuptools/command/install_egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 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 6aba68be..87cfc490 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -86,7 +86,6 @@ class install_egg_info(Command): if self.dry_run: return - f = open(filename, 'wt') for pkg in nsp: # ensure pkg is not a unicode string under Python 2.7 pkg = str(pkg) @@ -96,8 +95,9 @@ class install_egg_info(Command): if parent: tmpl_lines += self._nspkg_tmpl_multi dat = ';'.join(tmpl_lines) % locals() + '\n' + + with open(filename, 'wt') as f: f.write(dat) - f.close() def _get_all_ns_packages(self): """Return sorted list of all package namespaces""" -- cgit v1.2.1 From 63b852dff23dc86e983fceddde1463724a9d8a07 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 22 Jun 2014 10:15:21 -0400 Subject: Reindent long line --- setuptools/command/install_egg_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (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 87cfc490..67e183e1 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -64,7 +64,8 @@ class install_egg_info(Command): "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))", + "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)", ) -- cgit v1.2.1 From d8192350d95f3daf8831b58c80ded4d0d3393d7c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 22 Jun 2014 10:26:00 -0400 Subject: Extract method for generating lines for a pkg in nsp. Fixes issue in 67bdf3a726962 where only the last dat would be written. --- setuptools/command/install_egg_info.py | 49 ++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 23 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 67e183e1..35a00e54 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -60,6 +60,22 @@ class install_egg_info(Command): unpack_archive(self.source, self.target, skimmer) + def install_namespaces(self): + nsp = self._get_all_ns_packages() + if not nsp: + return + filename, ext = os.path.splitext(self.target) + filename += '-nspkg.pth' + self.outputs.append(filename) + log.info("Installing %s", filename) + if self.dry_run: + return + + lines = map(self._gen_nspkg_line, nsp) + + with open(filename, 'wt') as f: + list(map(f.write, lines)) + _nspkg_tmpl = ( "import sys, types, os", "p = os.path.join(sys._getframe(1).f_locals['sitedir'], *%(pth)r)", @@ -76,29 +92,16 @@ class install_egg_info(Command): ) "additional line(s) when a parent package is indicated" - def install_namespaces(self): - nsp = self._get_all_ns_packages() - if not nsp: - return - filename, ext = os.path.splitext(self.target) - filename += '-nspkg.pth' - self.outputs.append(filename) - log.info("Installing %s", filename) - if self.dry_run: - return - - for pkg in nsp: - # ensure pkg is not a unicode string under Python 2.7 - pkg = str(pkg) - pth = tuple(pkg.split('.')) - tmpl_lines = self._nspkg_tmpl - parent, sep, child = pkg.rpartition('.') - if parent: - tmpl_lines += self._nspkg_tmpl_multi - dat = ';'.join(tmpl_lines) % locals() + '\n' - - with open(filename, 'wt') as f: - f.write(dat) + @classmethod + def _gen_nspkg_line(cls, pkg): + # ensure pkg is not a unicode string under Python 2.7 + pkg = str(pkg) + pth = tuple(pkg.split('.')) + tmpl_lines = cls._nspkg_tmpl + parent, sep, child = pkg.rpartition('.') + if parent: + tmpl_lines += cls._nspkg_tmpl_multi + return ';'.join(tmpl_lines) % locals() + '\n' def _get_all_ns_packages(self): """Return sorted list of all package namespaces""" -- cgit v1.2.1 From c3f158dcc26b86008c7427674aec5ed100540280 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 22 Jun 2014 10:34:27 -0400 Subject: Prefer the writelines method. --- setuptools/command/install_egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 35a00e54..3e413898 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -74,7 +74,7 @@ class install_egg_info(Command): lines = map(self._gen_nspkg_line, nsp) with open(filename, 'wt') as f: - list(map(f.write, lines)) + f.writelines(lines) _nspkg_tmpl = ( "import sys, types, os", -- cgit v1.2.1 From 9d45f02e92ea875a88a964a629c0274d597f8d46 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 22 Jun 2014 10:37:24 -0400 Subject: Always generate the lines, even in dry run. --HG-- extra : amend_source : fa41c3fb787b667f703f67a52aed7a2958e615b4 --- setuptools/command/install_egg_info.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 3e413898..fd0f118b 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -68,11 +68,13 @@ class install_egg_info(Command): filename += '-nspkg.pth' self.outputs.append(filename) log.info("Installing %s", filename) + lines = map(self._gen_nspkg_line, nsp) + if self.dry_run: + # always generate the lines, even in dry run + list(lines) return - lines = map(self._gen_nspkg_line, nsp) - with open(filename, 'wt') as f: f.writelines(lines) -- cgit v1.2.1 From b54668a95934f1f63647e219cbbcbeab4a524ac3 Mon Sep 17 00:00:00 2001 From: Jesse Weinstein Date: Thu, 28 Aug 2014 20:55:27 +0000 Subject: Fix issue #118: Prevent the egg-info directory from being redundantly included in the list of modified files. --HG-- extra : rebase_source : 8bad8bf37ef1fdc59b4c1ba21fcff43d25f9b2be --- setuptools/command/install_egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 fd0f118b..992709f1 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -27,7 +27,7 @@ class install_egg_info(Command): ).egg_name() + '.egg-info' self.source = ei_cmd.egg_info self.target = os.path.join(self.install_dir, basename) - self.outputs = [self.target] + self.outputs = [] def run(self): self.run_command('egg_info') -- cgit v1.2.1 From 946652ee4def4236696a00d8873186bb07f15c71 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 29 Sep 2014 08:38:08 -0400 Subject: Backout 5692cd26a08e; Ref #262. --- setuptools/command/install_egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 992709f1..fd0f118b 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -27,7 +27,7 @@ class install_egg_info(Command): ).egg_name() + '.egg-info' self.source = ei_cmd.egg_info self.target = os.path.join(self.install_dir, basename) - self.outputs = [] + self.outputs = [self.target] def run(self): self.run_command('egg_info') -- cgit v1.2.1 From 8af3b6ef5b4173a0d0d6735147c98c882ae98344 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Jan 2016 06:54:00 -0500 Subject: Always use Python 3 version of map --- setuptools/command/install_egg_info.py | 2 ++ 1 file changed, 2 insertions(+) (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 fd0f118b..f777538f 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -1,6 +1,8 @@ from distutils import log, dir_util import os +from setuptools.extern.six.moves import map + from setuptools import Command from setuptools.archive_util import unpack_archive import pkg_resources -- cgit v1.2.1 From 0e689bb35e8af9f079f6985a11c80268575f786e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 7 Feb 2016 09:25:06 -0500 Subject: Backout changeset 1ae2a75724bbba56373784f185a7f235ed0f24a4 --- setuptools/command/install_egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 fd0f118b..992709f1 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -27,7 +27,7 @@ class install_egg_info(Command): ).egg_name() + '.egg-info' self.source = ei_cmd.egg_info self.target = os.path.join(self.install_dir, basename) - self.outputs = [self.target] + self.outputs = [] def run(self): self.run_command('egg_info') -- cgit v1.2.1 From e6d7c40652743005e70ddec1a3e5c7466e52a313 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 1 Oct 2016 11:59:36 -0400 Subject: Disable nspkg.pth behavior on Python 3.3+. Fixes #805 and fixes pypa/pip#1924. --- setuptools/command/install_egg_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (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 60b615d2..7834e107 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -82,9 +82,10 @@ class install_egg_info(Command): _nspkg_tmpl = ( "import sys, types, os", + "pep420 = sys.version_info > (3, 3)", "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 " + "m = not ie and not pep420 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)", -- cgit v1.2.1 From d5494571842c63e4b1903d8f455727e408464ff5 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 23 Oct 2016 09:25:03 -0400 Subject: Extract namespace handling into a separate module and mix-in class. --- setuptools/command/install_egg_info.py | 61 ++-------------------------------- 1 file changed, 2 insertions(+), 59 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 7834e107..edc4718b 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -1,14 +1,13 @@ from distutils import log, dir_util import os -from setuptools.extern.six.moves import map - from setuptools import Command +from setuptools import namespaces from setuptools.archive_util import unpack_archive import pkg_resources -class install_egg_info(Command): +class install_egg_info(namespaces.Installer, Command): """Install an .egg-info directory for the package""" description = "Install an .egg-info directory for the package" @@ -61,59 +60,3 @@ class install_egg_info(Command): return dst unpack_archive(self.source, self.target, skimmer) - - def install_namespaces(self): - nsp = self._get_all_ns_packages() - if not nsp: - return - filename, ext = os.path.splitext(self.target) - filename += '-nspkg.pth' - self.outputs.append(filename) - log.info("Installing %s", filename) - lines = map(self._gen_nspkg_line, nsp) - - if self.dry_run: - # always generate the lines, even in dry run - list(lines) - return - - with open(filename, 'wt') as f: - f.writelines(lines) - - _nspkg_tmpl = ( - "import sys, types, os", - "pep420 = sys.version_info > (3, 3)", - "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 not pep420 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)", - ) - "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" - - @classmethod - def _gen_nspkg_line(cls, pkg): - # ensure pkg is not a unicode string under Python 2.7 - pkg = str(pkg) - pth = tuple(pkg.split('.')) - tmpl_lines = cls._nspkg_tmpl - parent, sep, child = pkg.rpartition('.') - if parent: - tmpl_lines += cls._nspkg_tmpl_multi - return ';'.join(tmpl_lines) % locals() + '\n' - - def _get_all_ns_packages(self): - """Return sorted list of all package namespaces""" - nsp = set() - for pkg in self.distribution.namespace_packages or []: - pkg = pkg.split('.') - while pkg: - nsp.add('.'.join(pkg)) - pkg.pop() - return sorted(nsp) -- cgit v1.2.1 From 760e2e1df9c9c9d1fc072e7b6ad9df4c32bfc835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Fri, 27 Jul 2018 14:36:34 +0200 Subject: Remove spurious executable permissions --- setuptools/command/install_egg_info.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 setuptools/command/install_egg_info.py (limited to 'setuptools/command/install_egg_info.py') diff --git a/setuptools/command/install_egg_info.py b/setuptools/command/install_egg_info.py old mode 100755 new mode 100644 -- cgit v1.2.1