Install pip dependencies iteratively
Installing pip dependencies interatively (vs. concurrently) provides for interesting manifest syntax. For example, one could specify an index-url along side a dependency without affecting the other dependencies in the list.
This commit is contained in:
parent
5e3769d1e3
commit
37eed319e5
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue