From f587925899133c972d4e88f4cc0964e372a921d0 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Thu, 6 Dec 2012 17:57:03 -0800 Subject: [PATCH] Adjust pip adjustment function + remove unused dependencies. --- anvil/components/__init__.py | 32 +++++++++++----------------- anvil/components/glance.py | 16 ++++++++++---- anvil/components/glance_client.py | 6 ++---- anvil/components/horizon.py | 8 +++---- anvil/components/keystone.py | 8 +++---- anvil/components/nova.py | 9 ++++---- anvil/components/openstack_client.py | 13 +++++------ anvil/components/swift_client.py | 8 +++---- conf/distros/rhel.yaml | 8 ++----- 9 files changed, 48 insertions(+), 60 deletions(-) diff --git a/anvil/components/__init__.py b/anvil/components/__init__.py index ade808f0..cf62d3dd 100644 --- a/anvil/components/__init__.py +++ b/anvil/components/__init__.py @@ -426,34 +426,26 @@ class PythonInstallComponent(PkgInstallComponent): p_bar.update(i + 1) def _clean_pip_requires(self): - # Fixup these files if they exist (sometimes they have 'junk' in them) - req_fns = [] - for fn in self.requires_files: - if not sh.isfile(fn): - continue - req_fns.append(fn) + # Fixup these files if they exist, sometimes they have 'junk' in them + # that anvil will install instead of pip or setup.py and we don't want + # the setup.py file to attempt to install said dependencies since it + # typically picks locations that either are not what we desire or if + # said file contains editables, it may even pick external source directories + # which is what anvil is setting up as well... + req_fns = [f for f in self.requires_files if sh.isfile(f)] if req_fns: utils.log_iterable(req_fns, logger=LOG, header="Adjusting %s pip 'requires' files" % (len(req_fns))) for fn in req_fns: - new_lines = [] - for line in sh.load_file(fn).splitlines(): - s_line = line.strip() - if len(s_line) == 0: - continue - elif s_line.startswith("#"): - new_lines.append(s_line) - elif not self._filter_pip_requires_line(fn, s_line): - new_lines.append(("# %s" % (s_line))) - else: - new_lines.append(s_line) + old_lines = sh.load_file(fn).splitlines() + new_lines = self._filter_pip_requires(fn, old_lines) contents = "# Cleaned on %s\n\n%s\n" % (utils.iso8601(), "\n".join(new_lines)) sh.write_file_and_backup(fn, contents) return len(req_fns) - def _filter_pip_requires_line(self, fn, line): - # Return none to filter or the line itself to leave alone... - return line + def _filter_pip_requires(self, fn, lines): + # The default does no filtering except to ensure that said lines are valid... + return lines def pre_install(self): self._verify_pip_requires() diff --git a/anvil/components/glance.py b/anvil/components/glance.py index 5dd49e25..c5948926 100644 --- a/anvil/components/glance.py +++ b/anvil/components/glance.py @@ -69,10 +69,18 @@ class GlanceInstaller(comp.PythonInstallComponent): def config_files(self): return list(CONFIGS) - def _filter_pip_requires_line(self, fn, line): - if utils.has_any(line.lower(), 'swift', 'keystoneclient'): - return None - return line + def _filter_pip_requires(self, fn, lines): + new_lines = [] + for line in lines: + # Anvil handles installing these if needed + # and not setup.py + if utils.has_any(line.lower(), 'swift', 'keystoneclient'): + continue + elif line.strip().startswith("-e"): + continue + else: + new_lines.append(line) + return new_lines def pre_install(self): comp.PythonInstallComponent.pre_install(self) diff --git a/anvil/components/glance_client.py b/anvil/components/glance_client.py index 979c2cdc..69af75ee 100644 --- a/anvil/components/glance_client.py +++ b/anvil/components/glance_client.py @@ -18,10 +18,8 @@ from anvil import components as comp class GlanceClientInstaller(comp.PythonInstallComponent): - def _filter_pip_requires_line(self, fn, line): - if line.lower().find('keystoneclient') != -1: - return None - return line + def _filter_pip_requires(self, fn, lines): + return [l for l in lines if l.lower().find('keystoneclient') == -1] class GlanceClientTester(comp.PythonTestingComponent): diff --git a/anvil/components/horizon.py b/anvil/components/horizon.py index 7affb6bd..f0c6c914 100644 --- a/anvil/components/horizon.py +++ b/anvil/components/horizon.py @@ -66,13 +66,11 @@ class HorizonInstaller(comp.PythonInstallComponent): self.distro.get_command_config('apache', 'name'), 'horizon_error.log') - def _filter_pip_requires_line(self, fn, line): + def _filter_pip_requires(self, fn, lines): # Knock off all nova, quantum, swift, keystone, cinder # clients since anvil will be making sure those are installed - # instead of asking pip to do it... - if re.search(r'([n|q|s|k|g|c]\w+client)', line, re.I): - return None - return line + # instead of asking setup.py to do it... + return [l for l in lines if not re.search(r'([n|q|s|k|g|c]\w+client)', l, re.I)] def verify(self): comp.PythonInstallComponent.verify(self) diff --git a/anvil/components/keystone.py b/anvil/components/keystone.py index d3294a73..5cd06f91 100644 --- a/anvil/components/keystone.py +++ b/anvil/components/keystone.py @@ -70,10 +70,10 @@ class KeystoneInstaller(comp.PythonInstallComponent): comp.PythonInstallComponent.__init__(self, *args, **kargs) self.bin_dir = sh.joinpths(self.get_option('app_dir'), 'bin') - def _filter_pip_requires_line(self, fn, line): - if utils.has_any(line.lower(), 'keystoneclient', 'ldap', 'http://tarballs.openstack.org', 'memcached'): - return None - return line + def _filter_pip_requires(self, fn, lines): + return [l for l in lines + if not utils.has_any(l.lower(), 'keystoneclient', + 'ldap', 'http://tarballs.openstack.org', 'memcached')] def post_install(self): comp.PythonInstallComponent.post_install(self) diff --git a/anvil/components/nova.py b/anvil/components/nova.py index a1ea0dda..edb927c9 100644 --- a/anvil/components/nova.py +++ b/anvil/components/nova.py @@ -114,11 +114,10 @@ class NovaInstaller(comp.PythonInstallComponent): def config_files(self): return list(CONFIGS) - def _filter_pip_requires_line(self, fn, line): - # We handle these ourselves in anvil - if utils.has_any(line.lower(), 'quantumclient', 'cinder', 'glance', 'ldap', 'keystoneclient'): - return None - return line + def _filter_pip_requires(self, fn, lines): + return [l for l in lines + if not utils.has_any(l.lower(), 'quantumclient', + 'cinder', 'glance', 'ldap', 'keystoneclient')] @property def env_exports(self): diff --git a/anvil/components/openstack_client.py b/anvil/components/openstack_client.py index 6b5e656f..62f4f25c 100644 --- a/anvil/components/openstack_client.py +++ b/anvil/components/openstack_client.py @@ -15,17 +15,14 @@ # under the License. from anvil import components as comp +from anvil import utils class OpenStackClientInstaller(comp.PythonInstallComponent): - def _filter_pip_requires_line(self, fn, line): - if line.lower().find('keystoneclient') != -1: - return None - if line.lower().find('novaclient') != -1: - return None - if line.lower().find('glanceclient') != -1: - return None - return line + def _filter_pip_requires(self, fn, lines): + return [l for l in lines + if not utils.has_any(l.lower(), + 'keystoneclient', 'novaclient', 'glanceclient')] class OpenStackClientTester(comp.PythonTestingComponent): diff --git a/anvil/components/swift_client.py b/anvil/components/swift_client.py index 27e830d3..7532d80f 100644 --- a/anvil/components/swift_client.py +++ b/anvil/components/swift_client.py @@ -15,10 +15,10 @@ # under the License. from anvil import components as comp +from anvil import utils class SwiftClientInstaller(comp.PythonInstallComponent): - def _filter_pip_requires_line(self, fn, line): - if line.lower().find('keystoneclient') != -1: - return None - return line + def _filter_pip_requires(self, fn, lines): + return [l for l in lines + if not utils.has_any(l.lower(), 'keystoneclient')] diff --git a/conf/distros/rhel.yaml b/conf/distros/rhel.yaml index 5807f2be..1ceca21f 100644 --- a/conf/distros/rhel.yaml +++ b/conf/distros/rhel.yaml @@ -408,9 +408,6 @@ components: - name: suds package: name: python-suds - - name: paramiko - package: - name: python-paramiko - name: feedparser package: name: python-feedparser @@ -418,9 +415,8 @@ components: package: name: MySQL-python pips: - - name: Cheetah - version: "2.4.4" - - name: fixtures # Seems for testing only + # Seems for testing only?? + - name: fixtures subsystems: compute: packages: