Merge pull request #53 from blueboxgroup/iterative

Install pip dependencies iteratively
This commit is contained in:
Paul Czarkowski 2015-10-14 21:42:00 -05:00
commit e49298cc49
3 changed files with 14 additions and 25 deletions

View File

@ -39,11 +39,11 @@ class Builder(object):
def _get_gerrit_dependencies(self, repo, project):
try:
review = GerritReview(repo.head.change_id, project.git_path)
return review.build_pip_dependencies(string=True)
return review.build_pip_dependencies()
except Exception as e:
LOG.warning("Could not install gerrit dependencies!!! "
"Error was: %s", e)
return ""
return []
def _build_project(self, project):
self._prepare_project_build(project)
@ -57,15 +57,15 @@ class Builder(object):
# create and build the virtualenv
self._create_virtualenv(project.venv_command, project.install_path)
dependencies = ""
dependencies = []
if project.pip_dependencies:
dependencies = " ".join(project.pip_dependencies)
dependencies = project.pip_dependencies
if self._spec.settings.gerrit_dependencies:
dependencies = "%s %s" % (dependencies,
self._get_gerrit_dependencies(repo,
project))
dependencies += self._get_gerrit_dependencies(repo, project)
if len(dependencies):
self._install_pip_dependencies(project.install_path, dependencies)
self._install_pip_dependencies(project.install_path,
dependencies)
if self._spec.settings.include_config:
self._copy_sample_config(src_clone_dir, project)
@ -73,7 +73,8 @@ class Builder(object):
self._install_project(project.install_path, src_clone_dir)
if project.postinstall_dependencies:
self._install_postinstall_dependencies(project)
dependencies = project.postinstall_dependencies
self._install_pip_dependencies(project, dependencies)
# finish up
self._finalize_project_build(project)
@ -147,10 +148,6 @@ class Builder(object):
def _install_project(self, venv_path, src_clone_dir):
return
@abstractmethod
def _install_postinstall_dependencies(self, project):
return
@abstractmethod
def _finalize_project_build(self, project):
return

View File

@ -84,7 +84,8 @@ class DockerBuilder(Builder):
def _install_pip_dependencies(self, venv_path, dependencies):
pip_path = self._get_venv_pip_path(venv_path)
self._execute("%s install %s" % (pip_path, dependencies))
for dependency in dependencies:
self._execute("%s install %s" % (pip_path, dependency))
def _copy_sample_config(self, src_clone_dir, project):
src_config = os.path.join(src_clone_dir, 'etc')
@ -97,11 +98,6 @@ class DockerBuilder(Builder):
pip_path = self._get_venv_pip_path(venv_path)
self._execute("%s install %s" % (pip_path, src_clone_dir))
def _install_postinstall_dependencies(self, project):
pip_path = self._get_venv_pip_path(project.install_path)
dependencies = " ".join(project.postinstall_dependencies)
self._execute("%s install %s" % (pip_path, dependencies))
def _finalize_project_build(self, project):
self._commands.append("rm -rf %s" % self._temp_dir)
for command in self._commands:

View File

@ -70,7 +70,8 @@ class PackageBuilder(Builder):
def _install_pip_dependencies(self, venv_path, dependencies):
pip_path = self._get_venv_pip_path(venv_path)
self._execute("%s install %s" % (pip_path, dependencies))
for dependency in dependencies:
self._execute("%s install %s" % (pip_path, dependency))
def _copy_sample_config(self, src_clone_dir, project):
src_config = os.path.join(src_clone_dir, 'etc')
@ -88,11 +89,6 @@ class PackageBuilder(Builder):
pip_path = self._get_venv_pip_path(venv_path)
self._execute("%s install %s" % (pip_path, src_clone_dir))
def _install_postinstall_dependencies(self, project):
pip_path = self._get_venv_pip_path(project.install_path)
dependencies = " ".join(project.postinstall_dependencies)
self._execute("%s install %s" % (pip_path, dependencies))
def _finalize_project_build(self, project):
# build the package
pkg = Package(project.package_name, project.version,