From 1b38631781dd196e6d6b6e2487b6be5c07987c58 Mon Sep 17 00:00:00 2001 From: Matthew Scott Krafczyk Date: Wed, 18 Apr 2018 17:26:14 -0500 Subject: [PATCH] Add -d option to diy to specify source path move -j to common args (#5963) --- lib/spack/spack/cmd/common/arguments.py | 4 ++++ lib/spack/spack/cmd/diy.py | 16 +++++++++++++++- lib/spack/spack/cmd/install.py | 4 +--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/spack/spack/cmd/common/arguments.py b/lib/spack/spack/cmd/common/arguments.py index 59b2f4e14e..9f22d706ab 100644 --- a/lib/spack/spack/cmd/common/arguments.py +++ b/lib/spack/spack/cmd/common/arguments.py @@ -142,6 +142,10 @@ def __call__(self, parser, namespace, values, option_string=None): '-L', '--very-long', action='store_true', help='show full dependency hashes as well as versions') +_arguments['jobs'] = Args( + '-j', '--jobs', action='store', type=int, dest='jobs', + help="explicitely set number of make jobs. default is #cpus") + _arguments['tags'] = Args( '-t', '--tags', action='append', help='filter a package query by tags') diff --git a/lib/spack/spack/cmd/diy.py b/lib/spack/spack/cmd/diy.py index 8da2568def..ad9ca31071 100644 --- a/lib/spack/spack/cmd/diy.py +++ b/lib/spack/spack/cmd/diy.py @@ -39,6 +39,10 @@ def setup_parser(subparser): + arguments.add_common_arguments(subparser, ['jobs']) + subparser.add_argument( + '-d', '--source-path', dest='source_path', default=None, + help="path to source directory. defaults to the current directory") subparser.add_argument( '-i', '--ignore-dependencies', action='store_true', dest='ignore_deps', help="don't try to install dependencies of requested packages") @@ -63,6 +67,10 @@ def diy(self, args): if not args.spec: tty.die("spack diy requires a package spec argument.") + if args.jobs is not None: + if args.jobs <= 0: + tty.die("the -j option must be a positive integer") + specs = spack.cmd.parse_specs(args.spec) if len(specs) > 1: tty.die("spack diy only takes one spec.") @@ -85,13 +93,19 @@ def diy(self, args): tty.msg("Uninstall or try adding a version suffix for this DIY build.") sys.exit(1) + source_path = args.source_path + if source_path is None: + source_path = os.getcwd() + source_path = os.path.abspath(source_path) + # Forces the build to run out of the current directory. - package.stage = DIYStage(os.getcwd()) + package.stage = DIYStage(source_path) # TODO: make this an argument, not a global. spack.do_checksum = False package.do_install( + make_jobs=args.jobs, keep_prefix=args.keep_prefix, install_deps=not args.ignore_deps, verbose=not args.quiet, diff --git a/lib/spack/spack/cmd/install.py b/lib/spack/spack/cmd/install.py index bf5aa14376..a4c6e5932e 100644 --- a/lib/spack/spack/cmd/install.py +++ b/lib/spack/spack/cmd/install.py @@ -54,9 +54,7 @@ def setup_parser(subparser): alternatively one can decide to install only the package or only the dependencies""" ) - subparser.add_argument( - '-j', '--jobs', action='store', type=int, - help="explicitly set number of make jobs (default: #cpus)") + arguments.add_common_arguments(subparser, ['jobs']) subparser.add_argument( '--overwrite', action='store_true', help="reinstall an existing spec, even if it has dependents")