def define_virtual_constraints(self):
    'Define versions for constraints on virtuals.\n\n        Must be called before define_version_constraints().\n        '
    constraint_map = collections.defaultdict((lambda : set()))
    for (pkg_name, versions) in self.version_constraints:
        if (not spack.repo.path.is_virtual(pkg_name)):
            continue
        constraint_map[pkg_name].add(versions)

    def versions_for(v):
        if isinstance(v, spack.version.Version):
            return [v]
        elif isinstance(v, spack.version.VersionRange):
            result = ([v.start] if v.start else [])
            result += ([v.end] if v.end else [])
            return result
        elif isinstance(v, spack.version.VersionList):
            return sum((versions_for(e) for e in v), [])
        else:
            raise TypeError(('expected version type, found: %s' % type(v)))
    for (pkg_name, versions) in sorted(constraint_map.items()):
        possible_versions = set(sum([versions_for(v) for v in versions], []))
        for version in sorted(possible_versions):
            self.possible_versions[pkg_name].add(version)
Define versions for constraints on virtuals.

Must be called before define_version_constraints().
def define_virtual_constraints(self):
    'Define versions for constraints on virtuals.\n\n        Must be called before define_version_constraints().\n        '
    constraint_map = collections.defaultdict((lambda : set()))
    for (pkg_name, versions) in self.version_constraints:
        if (not spack.repo.path.is_virtual(pkg_name)):
            continue
        constraint_map[pkg_name].add(versions)

    def versions_for(v):
        if isinstance(v, spack.version.Version):
            return [v]
        elif isinstance(v, spack.version.VersionRange):
            result = ([v.start] if v.start else [])
            result += ([v.end] if v.end else [])
            return result
        elif isinstance(v, spack.version.VersionList):
            return sum((versions_for(e) for e in v), [])
        else:
            raise TypeError(('expected version type, found: %s' % type(v)))
    for (pkg_name, versions) in sorted(constraint_map.items()):
        possible_versions = set(sum([versions_for(v) for v in versions], []))
        for version in sorted(possible_versions):
            self.possible_versions[pkg_name].add(version)