summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGreg Becker <becker33@llnl.gov>2019-10-12 11:43:37 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2019-10-12 11:43:37 -0700
commit1808ba3c68c8a063157328883788eef4439785a9 (patch)
tree1301769dc06d8407998a83e878e22f448440b99f /lib
parentebb5ce4b69683c7ff87e100ee651e82ded66cb3d (diff)
downloadspack-1808ba3c68c8a063157328883788eef4439785a9.tar.gz
spack-1808ba3c68c8a063157328883788eef4439785a9.tar.bz2
spack-1808ba3c68c8a063157328883788eef4439785a9.tar.xz
spack-1808ba3c68c8a063157328883788eef4439785a9.zip
install: add --cache-only option (#12729)
* add `--cache-only` option to install * testing for `--cache-only` * remove extraneous stage creation at stage destroy time
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/bootstrap.py6
-rw-r--r--lib/spack/spack/cmd/install.py6
-rw-r--r--lib/spack/spack/package.py4
-rw-r--r--lib/spack/spack/test/cmd/install.py9
4 files changed, 22 insertions, 3 deletions
diff --git a/lib/spack/spack/cmd/bootstrap.py b/lib/spack/spack/cmd/bootstrap.py
index 27ebb7320d..71db75c788 100644
--- a/lib/spack/spack/cmd/bootstrap.py
+++ b/lib/spack/spack/cmd/bootstrap.py
@@ -34,6 +34,9 @@ def setup_parser(subparser):
cache_group.add_argument(
'--no-cache', action='store_false', dest='use_cache', default=True,
help="do not check for pre-built Spack packages in mirrors")
+ cache_group.add_argument(
+ '--cache-only', action='store_true', dest='cache_only', default=False,
+ help="only install package from binary mirrors")
cd_group = subparser.add_mutually_exclusive_group()
arguments.add_common_arguments(cd_group, ['clean', 'dirty'])
@@ -46,7 +49,8 @@ def bootstrap(parser, args, **kwargs):
'install_deps': 'dependencies',
'verbose': args.verbose,
'dirty': args.dirty,
- 'use_cache': args.use_cache
+ 'use_cache': args.use_cache,
+ 'cache_only': args.cache_only
})
# Define requirement dictionary defining general specs which need
diff --git a/lib/spack/spack/cmd/install.py b/lib/spack/spack/cmd/install.py
index b9923c7e1b..b625078a0b 100644
--- a/lib/spack/spack/cmd/install.py
+++ b/lib/spack/spack/cmd/install.py
@@ -38,7 +38,8 @@ def update_kwargs_from_args(args, kwargs):
'verbose': args.verbose,
'fake': args.fake,
'dirty': args.dirty,
- 'use_cache': args.use_cache
+ 'use_cache': args.use_cache,
+ 'cache_only': args.cache_only
})
if hasattr(args, 'setup'):
setups = set()
@@ -81,6 +82,9 @@ the dependencies"""
cache_group.add_argument(
'--no-cache', action='store_false', dest='use_cache', default=True,
help="do not check for pre-built Spack packages in mirrors")
+ cache_group.add_argument(
+ '--cache-only', action='store_true', dest='cache_only', default=False,
+ help="only install package from binary mirrors")
subparser.add_argument(
'--show-log-on-error', action='store_true',
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index e8d78a6ac7..686bbc2e1e 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -1499,6 +1499,7 @@ class PackageBase(with_metaclass(PackageMeta, PackageViewMixin, object)):
restage (bool): Force spack to restage the package source.
force (bool): Install again, even if already installed.
use_cache (bool): Install from binary package, if available.
+ cache_only (bool): Fail if binary package unavailable.
stop_at (InstallPhase): last installation phase to be executed
(or None)
"""
@@ -1577,6 +1578,8 @@ class PackageBase(with_metaclass(PackageMeta, PackageViewMixin, object)):
print_pkg(self.prefix)
spack.hooks.post_install(self.spec)
return
+ elif kwargs.get('cache_only', False):
+ tty.die('No binary for %s found and cache-only specified')
tty.msg('No binary for %s found: installing from source'
% self.name)
@@ -1792,7 +1795,6 @@ class PackageBase(with_metaclass(PackageMeta, PackageViewMixin, object)):
if restage and self.stage.managed_by_spack:
self.stage.destroy()
- self.stage.create()
return partial
diff --git a/lib/spack/spack/test/cmd/install.py b/lib/spack/spack/test/cmd/install.py
index 5b5ee1bc49..3892a1da7b 100644
--- a/lib/spack/spack/test/cmd/install.py
+++ b/lib/spack/spack/test/cmd/install.py
@@ -591,3 +591,12 @@ def test_build_warning_output(tmpdir, mock_fetch, install_mockery, capfd):
assert 'WARNING: ALL CAPITAL WARNING!' in msg
assert 'foo.c:89: warning: some weird warning!' in msg
+
+
+def test_cache_only_fails(tmpdir, mock_fetch, install_mockery, capfd):
+ with capfd.disabled():
+ try:
+ install('--cache-only', 'libdwarf')
+ assert False
+ except spack.main.SpackCommandError:
+ pass