'Called by commands to install a package and its dependencies.
Package implementations should override install() to describe
their build process.
Args:
keep_prefix (bool): Keep install prefix on failure. By default,
destroys it.
keep_stage (bool): By default, stage is destroyed only if there
are no exceptions during build. Set to True to keep the stage
even with exceptions.
install_deps (bool): Install dependencies before installing this
package
skip_patch (bool): Skip patch stage of build if True.
verbose (bool): Display verbose build output (by default,
suppresses it)
make_jobs (int): Number of make jobs to use for install. Default
is ncpus
run_tests (bool): Run tests within the package\'s install()
fake (bool): Don\'t really build; install fake stub files instead.
explicit (bool): True if package was explicitly installed, False
if package was implicitly installed (as a dependency).
dirty (bool): Don\'t clean the build environment before installing.
force (bool): Install again, even if already installed.'

def do_install(self, keep_prefix=False, keep_stage=False, install_deps=True, skip_patch=False, verbose=False, make_jobs=None, run_tests=False, fake=False, explicit=False, dirty=None, **kwargs):

    if (not self.spec.concrete):
        raise ValueError(('Can    only    install    concrete    packages:    %s.' % self.spec.name))
    if self.spec.external:
        return self._process_external_package(explicit)
    restage = kwargs.get('restage', False)
    partial = self.check_for_unfinished_installation(keep_prefix, restage)
    layout = spack.store.layout
    with spack.store.db.prefix_read_lock(self.spec):
        if partial:
            tty.msg(('Continuing    from    partial    install    of    %s' % self.name))
        elif layout.check_installed(self.spec):
            msg = '{0.name}    is    already    installed    in    {0.prefix}'
            tty.msg(msg.format(self))
            rec = spack.store.db.get_record(self.spec)
            return self._update_explicit_entry_in_db(rec, explicit)
    if (dirty is None):
        dirty = spack.dirty
    self._do_install_pop_kwargs(kwargs)
    if install_deps:
        tty.debug('Installing    {0}    dependencies'.format(self.name))
        for dep in self.spec.dependencies():
            dep.package.do_install(keep_prefix=keep_prefix, keep_stage=keep_stage, install_deps=install_deps, fake=fake, skip_patch=skip_patch, verbose=verbose, make_jobs=make_jobs, run_tests=run_tests, dirty=dirty, **kwargs)
    tty.msg(('Installing    %s' % self.name))
    self.run_tests = run_tests
    self.make_jobs = make_jobs
    def build_process(input_stream):
        'Forked    for    each    build.    Has    its    own    process    and    python\n                                                            module    space    set    up    by    build_environment.fork().'
        sys.stdin = input_stream
        start_time = time.time()
        if (not fake):
            if (not skip_patch):
                self.do_patch()
            else:
                self.do_stage()
        tty.msg('Building    {0}    [{1}]'.format(self.name, self.build_system_class))
        self.stage.keep = keep_stage
        with self._stage_and_write_lock():
            spack.hooks.pre_install(self.spec)
            if fake:
                self.do_fake_install()
            else:
                self.stage.chdir_to_source()
                env_path = join_path(os.getcwd(), 'spack-build.env')
                log_path = join_path(os.getcwd(), 'spack-build.out')
                self.log_path = log_path
                self.env_path = env_path
                dump_environment(env_path)
                redirection_context = log_output(log_path, echo=verbose, force_color=sys.stdout.isatty(), debug=True, input_stream=input_stream)
                with redirection_context as log_redirection:
                    for (phase_name, phase) in zip(self.phases, self._InstallPhase_phases):
                        tty.msg("Executing    phase    :    '{0}'".format(phase_name))
                        with log_redirection:
                            getattr(self, phase)(self.spec, self.prefix)
                self.log()
            spack.hooks.post_install(self.spec)
        self._total_time = (time.time() - start_time)
        build_time = (self._total_time - self._fetch_time)
        tty.msg(('Successfully    installed    %s' % self.name), ('Fetch:    %s.        Build:    %s.        Total:    %s.' % (_hms(self._fetch_time), _hms(build_time), _hms(self._total_time))))
        print_pkg(self.prefix)
    try:
        if (not os.path.exists(self.prefix)):
            spack.store.layout.create_install_directory(self.spec)
        spack.build_environment.fork(self, build_process, dirty=dirty)
        keep_prefix = ((self.last_phase is None) or keep_prefix)
        spack.store.db.add(self.spec, spack.store.layout, explicit=explicit)
    except directory_layout.InstallDirectoryAlreadyExistsError:
        tty.warn('Keeping    existing    install    prefix    in    place.')
        raise
    except StopIteration as e:
        tty.msg(e.message)
        tty.msg('Package    stage    directory    :    {0}'.format(self.stage.source_path))
    finally:
        if (not keep_prefix):
            self.remove_prefix()
