summaryrefslogtreecommitdiff
path: root/setuptools/command/install_lib.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2014-09-26 10:29:38 -0400
committerJason R. Coombs <jaraco@jaraco.com>2014-09-26 10:29:38 -0400
commitbd62121950280590c9388db065df389cf2d8280d (patch)
tree0ed93aaa20e6b8c5c45cd58e7d9508cb058068dc /setuptools/command/install_lib.py
parente8914480487426305fece22422fdb725f88add7f (diff)
downloadpython-setuptools-git-bd62121950280590c9388db065df389cf2d8280d.tar.gz
Extract method for calculating namespace packages for single_version_externally_managed
Diffstat (limited to 'setuptools/command/install_lib.py')
-rw-r--r--setuptools/command/install_lib.py34
1 files changed, 23 insertions, 11 deletions
diff --git a/setuptools/command/install_lib.py b/setuptools/command/install_lib.py
index 91d2b25d..bf587a04 100644
--- a/setuptools/command/install_lib.py
+++ b/setuptools/command/install_lib.py
@@ -17,19 +17,31 @@ class install_lib(orig.install_lib):
excluded for single_version_externally_managed installations.
"""
exclude = set()
- 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.add(os.path.join(pkgdir, f))
- parts.pop()
+ for pkg in self._get_SVEM_NSPs():
+ parts = pkg.split('.')
+ while parts:
+ pkgdir = os.path.join(self.install_dir, *parts)
+ for f in self._gen_exclude_names():
+ exclude.add(os.path.join(pkgdir, f))
+ parts.pop()
return exclude
+ def _get_SVEM_NSPs(self):
+ """
+ Get namespace packages (list) but only for
+ single_version_externally_managed installations and empty otherwise.
+ """
+ # TODO: is it necessary to short-circuit here? i.e. what's the cost
+ # if get_finalized_command is called even when namespace_packages is
+ # False?
+ if not self.distribution.namespace_packages:
+ return []
+
+ install_cmd = self.get_finalized_command('install')
+ svem = install_cmd.single_version_externally_managed
+
+ return self.distribution.namespace_packages if svem else []
+
@staticmethod
def _gen_exclude_names():
"""