Support postinstall python dependencies

There are cases where you would like for a Python module to be
installed *after* the project itself has been installed. This is now
possible with project.postinstall_dependencies.
This commit is contained in:
Craig Tracey 2015-10-09 23:25:38 -04:00
parent d31d804266
commit 5df2dff2f2
4 changed files with 20 additions and 1 deletions

View File

@ -71,6 +71,9 @@ class Builder(object):
self._install_project(project.install_path, src_clone_dir)
if project.postinstall_dependencies:
self._install_postinstall_dependencies(project)
# finish up
self._finalize_project_build(project)
@ -132,6 +135,10 @@ 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

@ -97,6 +97,11 @@ 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

@ -88,6 +88,11 @@ 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,

View File

@ -34,7 +34,8 @@ class OpenstackProject(object):
def __init__(self, settings, name, version=None, gitref=None, giturl=None,
gitdepth=1, venv_command=None, install_command=None,
install_path=None, package_name=None, stackforge=False,
system_dependencies=[], pip_dependencies=[]):
system_dependencies=[], pip_dependencies=[],
postinstall_dependencies=[]):
self._settings = settings
self.name = name
self._version = version
@ -49,6 +50,7 @@ class OpenstackProject(object):
self._git_path = None
self.system_dependencies = system_dependencies
self.pip_dependencies = pip_dependencies
self.postinstall_dependencies = postinstall_dependencies
@property
def version(self):