From bdf48322696290d4e3d00ed12b7c7fe6ca213478 Mon Sep 17 00:00:00 2001 From: alalazo Date: Sat, 22 Oct 2016 17:08:52 +0200 Subject: spack build, spack configure : added commands --- lib/spack/spack/cmd/build.py | 43 +++++++++++++++++++ lib/spack/spack/cmd/configure.py | 90 ++++++++++++++++++++++++++++++++++++++++ lib/spack/spack/cmd/install.py | 6 +-- lib/spack/spack/package.py | 10 ++--- 4 files changed, 139 insertions(+), 10 deletions(-) create mode 100644 lib/spack/spack/cmd/build.py create mode 100644 lib/spack/spack/cmd/configure.py (limited to 'lib') diff --git a/lib/spack/spack/cmd/build.py b/lib/spack/spack/cmd/build.py new file mode 100644 index 0000000000..1c43acc2b3 --- /dev/null +++ b/lib/spack/spack/cmd/build.py @@ -0,0 +1,43 @@ +############################################################################## +# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC. +# Produced at the Lawrence Livermore National Laboratory. +# +# This file is part of Spack. +# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. +# LLNL-CODE-647188 +# +# For details, see https://github.com/llnl/spack +# Please also see the LICENSE file for our notice and the LGPL. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License (as +# published by the Free Software Foundation) version 2.1, February 1999. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and +# conditions of the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +############################################################################## + +import spack.cmd.configure as cfg + +from spack import * + +description = 'Stops at build stage when installing a package, if possible' + +build_system_to_phase = { + CMakePackage: 'build', + AutotoolsPackage: 'build' +} + + +def setup_parser(subparser): + cfg.setup_parser(subparser) + + +def build(parser, args): + cfg._stop_at_phase_during_install(args, build, build_system_to_phase) diff --git a/lib/spack/spack/cmd/configure.py b/lib/spack/spack/cmd/configure.py new file mode 100644 index 0000000000..3eebe2584b --- /dev/null +++ b/lib/spack/spack/cmd/configure.py @@ -0,0 +1,90 @@ +############################################################################## +# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC. +# Produced at the Lawrence Livermore National Laboratory. +# +# This file is part of Spack. +# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. +# LLNL-CODE-647188 +# +# For details, see https://github.com/llnl/spack +# Please also see the LICENSE file for our notice and the LGPL. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License (as +# published by the Free Software Foundation) version 2.1, February 1999. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and +# conditions of the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +############################################################################## + +import argparse + +import llnl.util.tty as tty +import spack.cmd +import spack.cmd.install as inst + +from spack import * + +description = 'Stops at configuration stage when installing a package, if possible' # NOQA: ignore=E501 + + +build_system_to_phase = { + CMakePackage: 'cmake', + AutotoolsPackage: 'configure' +} + + +def setup_parser(subparser): + subparser.add_argument( + 'package', + nargs=argparse.REMAINDER, + help="spec of the package to install" + ) + subparser.add_argument( + '-v', '--verbose', + action='store_true', + help="Print additional output during builds" + ) + + +def _stop_at_phase_during_install(args, calling_fn, phase_mapping): + if not args.package: + tty.die("configure requires at least one package argument") + + # TODO: to be refactored with code in install + specs = spack.cmd.parse_specs(args.package, concretize=True) + if len(specs) != 1: + tty.error('only one spec can be installed at a time.') + spec = specs.pop() + pkg = spec.package + try: + key = [cls for cls in phase_mapping if isinstance(pkg, cls)].pop() + phase = phase_mapping[key] + # Install package dependencies if needed + parser = argparse.ArgumentParser() + inst.setup_parser(parser) + tty.msg('Checking dependencies for {0}'.format(args.package)) + cli_args = ['-v'] if args.verbose else [] + install_args = parser.parse_args(cli_args + ['--only=dependencies']) + install_args.package = args.package + inst.install(parser, install_args) + # Install package and stop at the given phase + cli_args = ['-v'] if args.verbose else [] + install_args = parser.parse_args(cli_args + ['--only=package']) + install_args.package = args.package + inst.install(parser, install_args, stop_at=phase) + except IndexError: + tty.error( + 'Package {0} has no {1} phase, or its {1} phase is not separated from install'.format( # NOQA: ignore=E501 + spec.name, calling_fn.__name__) + ) + + +def configure(parser, args): + _stop_at_phase_during_install(args, configure, build_system_to_phase) diff --git a/lib/spack/spack/cmd/install.py b/lib/spack/spack/cmd/install.py index 6ca75d7999..aab7c0abc7 100644 --- a/lib/spack/spack/cmd/install.py +++ b/lib/spack/spack/cmd/install.py @@ -74,7 +74,7 @@ the dependencies.""" help="Run tests during installation of a package.") -def install(parser, args): +def install(parser, args, **kwargs): if not args.package: tty.die("install requires at least one package argument") @@ -87,7 +87,7 @@ def install(parser, args): # Parse cli arguments and construct a dictionary # that will be passed to Package.do_install API - kwargs = { + kwargs.update({ 'keep_prefix': args.keep_prefix, 'keep_stage': args.keep_stage, 'install_deps': 'dependencies' in args.things_to_install, @@ -96,7 +96,7 @@ def install(parser, args): 'verbose': args.verbose, 'fake': args.fake, 'dirty': args.dirty - } + }) # Spec from cli specs = spack.cmd.parse_specs(args.package, concretize=True) diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 7eb5446a30..99796104a5 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -1263,13 +1263,9 @@ class PackageBase(object): # A StopIteration exception means that do_install # was asked to stop early from clients tty.msg(e.message) - except Exception: - tty.warn("Keeping install prefix in place despite error.", - "Spack will think this package is installed. " + - "Manually remove this directory to fix:", - self.prefix, - wrap=False) - raise + tty.msg( + 'Package stage directory : {0}'.format(self.stage.source_path) + ) finally: # Remove the install prefix if anything went wrong during install. if not keep_prefix: -- cgit v1.2.3-60-g2f50