From 98797459f343c400f4f6fe988bae47d4bab9116b Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Sat, 9 Aug 2014 17:41:56 -0700 Subject: Minor tweaks after spec update. - spack find -p works properly (get path from spec, not package) - directory layout and PackageDB normalize things automatically unless they're unknown packages (need to do this for spack find -l) - install test made robust to mock/main package conflicts --- lib/spack/spack/cmd/find.py | 2 +- lib/spack/spack/directory_layout.py | 6 ++++++ lib/spack/spack/packages.py | 8 +++++++- lib/spack/spack/test/install.py | 16 +++++++++++++++- 4 files changed, 29 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/cmd/find.py b/lib/spack/spack/cmd/find.py index 7f2bce119e..72df69d18a 100644 --- a/lib/spack/spack/cmd/find.py +++ b/lib/spack/spack/cmd/find.py @@ -89,7 +89,7 @@ def find(parser, args): format = " %-{}s%s".format(width) for abbrv, spec in zip(abbreviated, specs): - print format % (abbrv, spec.package.prefix) + print format % (abbrv, spec.prefix) elif args.full_specs: for spec in specs: diff --git a/lib/spack/spack/directory_layout.py b/lib/spack/spack/directory_layout.py index 816c945707..9b31aad5fe 100644 --- a/lib/spack/spack/directory_layout.py +++ b/lib/spack/spack/directory_layout.py @@ -29,6 +29,7 @@ import hashlib import shutil from contextlib import closing +import llnl.util.tty as tty from llnl.util.filesystem import join_path, mkdirp import spack @@ -163,6 +164,11 @@ class SpecHashDirectoryLayout(DirectoryLayout): if not spack.db.exists(spec.name): spec._normal = True spec._concrete = True + else: + spec.normalize() + if not spec.concrete: + tty.warn("Spec read from installed package is not concrete:", + path, spec) return spec diff --git a/lib/spack/spack/packages.py b/lib/spack/spack/packages.py index 744ccae2d1..ba997bf269 100644 --- a/lib/spack/spack/packages.py +++ b/lib/spack/spack/packages.py @@ -115,7 +115,13 @@ class PackageDB(object): """Read installed package names straight from the install directory layout. """ - return spack.install_layout.all_specs() + # Get specs from the directory layout but ensure that they're + # all normalized properly. + installed = [] + for spec in spack.install_layout.all_specs(): + spec.normalize() + installed.append(spec) + return installed @memoized diff --git a/lib/spack/spack/test/install.py b/lib/spack/spack/test/install.py index a92bd92289..8047ab92e3 100644 --- a/lib/spack/spack/test/install.py +++ b/lib/spack/spack/test/install.py @@ -25,15 +25,18 @@ import os import unittest import shutil +import tempfile from contextlib import closing from llnl.util.filesystem import * import spack from spack.stage import Stage +from spack.directory_layout import SpecHashDirectoryLayout from spack.util.executable import which from spack.test.mock_packages_test import * + dir_name = 'trivial-1.0' archive_name = 'trivial-1.0.tar.gz' install_test_package = 'trivial_install_test_package' @@ -66,9 +69,16 @@ class InstallTest(MockPackagesTest): tar = which('tar') tar('-czf', archive_name, dir_name) - # We use a fake pacakge, so skip the checksum. + # We use a fake package, so skip the checksum. spack.do_checksum = False + # Use a fake install directory to avoid conflicts bt/w + # installed pkgs and mock packages. + self.tmpdir = tempfile.mkdtemp() + self.orig_layout = spack.install_layout + spack.install_layout = SpecHashDirectoryLayout(self.tmpdir) + + def tearDown(self): super(InstallTest, self).tearDown() @@ -78,6 +88,10 @@ class InstallTest(MockPackagesTest): # Turn checksumming back on spack.do_checksum = True + # restore spack's layout. + spack.install_layout = self.orig_layout + shutil.rmtree(self.tmpdir, ignore_errors=True) + def test_install_and_uninstall(self): # Get a basic concrete spec for the trivial install package. -- cgit v1.2.3-60-g2f50