diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2014-09-26 10:29:38 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2014-09-26 10:29:38 -0400 |
commit | bd62121950280590c9388db065df389cf2d8280d (patch) | |
tree | 0ed93aaa20e6b8c5c45cd58e7d9508cb058068dc /setuptools/command/install_lib.py | |
parent | e8914480487426305fece22422fdb725f88add7f (diff) | |
download | python-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.py | 34 |
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(): """ |