Exemple #1
0
    def test_ambiguous_hash(self, database):
        x1 = Spec('a')
        x1._hash = 'xy'
        x1._concrete = True
        x2 = Spec('a')
        x2._hash = 'xx'
        x2._concrete = True
        database.add(x1, spack.store.layout)
        database.add(x2, spack.store.layout)

        # ambiguity in first hash character
        self._check_raises(AmbiguousHashError, ['/x'])

        # ambiguity in first hash character AND spec name
        self._check_raises(AmbiguousHashError, ['a/x'])
Exemple #2
0
    def read_spec(self, path):
        """Read the contents of a file and parse them as a spec"""
        with closing(open(path)) as spec_file:
            # Specs from files are assumed normal and concrete
            spec = Spec(spec_file.read().replace('\n', ''))

        if all(spack.db.exists(s.name) for s in spec.traverse()):
            copy = spec.copy()

            # TODO: It takes a lot of time to normalize every spec on read.
            # TODO: Storing graph info with spec files would fix this.
            copy.normalize()
            if copy.concrete:
                return copy   # These are specs spack still understands.

        # If we get here, either the spec is no longer in spack, or
        # something about its dependencies has changed. So we need to
        # just assume the read spec is correct.  We'll lose graph
        # information if we do this, but this is just for best effort
        # for commands like uninstall and find.  Currently Spack
        # doesn't do anything that needs the graph info after install.

        # TODO: store specs with full connectivity information, so
        # that we don't have to normalize or reconstruct based on
        # changing dependencies in the Spack tree.
        spec._normal = True
        spec._concrete = True
        return spec
Exemple #3
0
    def read_spec(self, path):
        """Read the contents of a file and parse them as a spec"""
        with closing(open(path)) as spec_file:
            # Specs from files are assumed normal and concrete
            spec = Spec(spec_file.read().replace('\n', ''))

        if all(spack.db.exists(s.name) for s in spec.traverse()):
            copy = spec.copy()

            # TODO: It takes a lot of time to normalize every spec on read.
            # TODO: Storing graph info with spec files would fix this.
            copy.normalize()
            if copy.concrete:
                return copy  # These are specs spack still understands.

        # If we get here, either the spec is no longer in spack, or
        # something about its dependencies has changed. So we need to
        # just assume the read spec is correct.  We'll lose graph
        # information if we do this, but this is just for best effort
        # for commands like uninstall and find.  Currently Spack
        # doesn't do anything that needs the graph info after install.

        # TODO: store specs with full connectivity information, so
        # that we don't have to normalize or reconstruct based on
        # changing dependencies in the Spack tree.
        spec._normal = True
        spec._concrete = True
        return spec
Exemple #4
0
    def test_regression_issue_4492(self):
        # Constructing a spec which has no dependencies, but is otherwise
        # concrete is kind of difficult. What we will do is to concretize
        # a spec, and then modify it to have no dependency and reset the
        # cache values.

        s = Spec('mpileaks')
        s.concretize()

        # Check that now the Spec is concrete, store the hash
        assert s.concrete

        # Remove the dependencies and reset caches
        s._dependencies.clear()
        s._concrete = False

        assert not s.concrete
Exemple #5
0
    def test_regression_issue_4492(self):
        # Constructing a spec which has no dependencies, but is otherwise
        # concrete is kind of difficult. What we will do is to concretize
        # a spec, and then modify it to have no dependency and reset the
        # cache values.

        s = Spec('mpileaks')
        s.concretize()

        # Check that now the Spec is concrete, store the hash
        assert s.concrete

        # Remove the dependencies and reset caches
        s._dependencies.clear()
        s._concrete = False

        assert not s.concrete
Exemple #6
0
    def read_spec(self, path):
        """Read the contents of a file and parse them as a spec"""
        with closing(open(path)) as spec_file:
            # Specs from files are assumed normal and concrete
            spec = Spec(spec_file.read().replace('\n', ''))

        # If we do not have a package on hand for this spec, we know
        # it is concrete, and we *assume* that it is normal. This
        # prevents us from trying to fetch a non-existing package, and
        # allows best effort for commands like spack find.
        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
Exemple #7
0
    def read_spec(self, path):
        """Read the contents of a file and parse them as a spec"""
        with closing(open(path)) as spec_file:
            # Specs from files are assumed normal and concrete
            spec = Spec(spec_file.read().replace('\n', ''))

        # If we do not have a package on hand for this spec, we know
        # it is concrete, and we *assume* that it is normal. This
        # prevents us from trying to fetch a non-existing package, and
        # allows best effort for commands like spack find.
        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