summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2014-09-26 10:02:01 -0400
committerJason R. Coombs <jaraco@jaraco.com>2014-09-26 10:02:01 -0400
commit8f5ca6ed5efe1523a511325a1d1c620ead832646 (patch)
tree491e91b7332ebf2608932d5ebcf235f43bf6e459
parentfc7d696c5a6af1aefa7daf9131893b5b5065cdb0 (diff)
downloadpython-setuptools-bitbucket-8f5ca6ed5efe1523a511325a1d1c620ead832646.tar.gz
Extract method for generating exclude names
-rw-r--r--setuptools/command/install_lib.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/setuptools/command/install_lib.py b/setuptools/command/install_lib.py
index c0c271a4..259f0899 100644
--- a/setuptools/command/install_lib.py
+++ b/setuptools/command/install_lib.py
@@ -16,6 +16,22 @@ class install_lib(orig.install_lib):
nsp = self.distribution.namespace_packages
svem = (nsp and self.get_finalized_command('install')
.single_version_externally_managed)
+ if svem:
+ for pkg in nsp:
+ parts = pkg.split('.')
+ while parts:
+ pkgdir = os.path.join(self.install_dir, *parts)
+ for f in self._gen_exclude_names():
+ exclude[os.path.join(pkgdir, f)] = 1
+ parts.pop()
+ return exclude
+
+ @staticmethod
+ def _gen_exclude_names():
+ """
+ Generate the list of file paths to be excluded for namespace
+ packages (bytecode cache files).
+ """
exclude_names = ['__init__.py', '__init__.pyc', '__init__.pyo']
if hasattr(imp, 'get_tag'):
exclude_names.extend((
@@ -28,15 +44,7 @@ class install_lib(orig.install_lib):
'__init__.' + imp.get_tag() + '.pyo'
),
))
- if svem:
- for pkg in nsp:
- parts = pkg.split('.')
- while parts:
- pkgdir = os.path.join(self.install_dir, *parts)
- for f in exclude_names:
- exclude[os.path.join(pkgdir, f)] = 1
- parts.pop()
- return exclude
+ return exclude_names
def copy_tree(
self, infile, outfile,