def pkg_rules(self, pkg, tests):
    pkg = packagize(pkg)
    self.pkg_version_rules(pkg)
    self.gen.newline()
    for (name, variant) in sorted(pkg.variants.items()):
        self.gen.fact(fn.variant(pkg.name, name))
        single_value = (not variant.multi)
        if single_value:
            self.gen.fact(fn.variant_single_value(pkg.name, name))
            self.gen.fact(fn.variant_default_value_from_package_py(pkg.name, name, variant.default))
        else:
            spec_variant = variant.make_default()
            defaults = spec_variant.value
            for val in sorted(defaults):
                self.gen.fact(fn.variant_default_value_from_package_py(pkg.name, name, val))
        values = variant.values
        if (values is None):
            values = []
        elif isinstance(values, spack.variant.DisjointSetsOfValues):
            union = set()
            for (sid, s) in enumerate(values.sets):
                for value in s:
                    self.gen.fact(fn.variant_value_from_disjoint_sets(pkg.name, name, value, sid))
                union.update(s)
            values = union
        if (not values):
            values = [variant.default]
        for value in sorted(values):
            self.gen.fact(fn.variant_possible_value(pkg.name, name, value))
        self.gen.newline()
    self.conflict_rules(pkg)
    self.package_compiler_defaults(pkg)
    self.package_provider_rules(pkg)
    self.package_dependencies_rules(pkg, tests)
    self.virtual_preferences(pkg.name, (lambda v, p, i: self.gen.fact(fn.pkg_provider_preference(pkg.name, v, p, i))))
def pkg_rules(self, pkg, tests):
    pkg = packagize(pkg)
    self.pkg_version_rules(pkg)
    self.gen.newline()
    for (name, variant) in sorted(pkg.variants.items()):
        self.gen.fact(fn.variant(pkg.name, name))
        single_value = (not variant.multi)
        if single_value:
            self.gen.fact(fn.variant_single_value(pkg.name, name))
            self.gen.fact(fn.variant_default_value_from_package_py(pkg.name, name, variant.default))
        else:
            spec_variant = variant.make_default()
            defaults = spec_variant.value
            for val in sorted(defaults):
                self.gen.fact(fn.variant_default_value_from_package_py(pkg.name, name, val))
        values = variant.values
        if (values is None):
            values = []
        elif isinstance(values, spack.variant.DisjointSetsOfValues):
            union = set()
            for (sid, s) in enumerate(values.sets):
                for value in s:
                    self.gen.fact(fn.variant_value_from_disjoint_sets(pkg.name, name, value, sid))
                union.update(s)
            values = union
        if (not values):
            values = [variant.default]
        for value in sorted(values):
            self.gen.fact(fn.variant_possible_value(pkg.name, name, value))
        self.gen.newline()
    self.conflict_rules(pkg)
    self.package_compiler_defaults(pkg)
    self.package_provider_rules(pkg)
    self.package_dependencies_rules(pkg, tests)
    self.virtual_preferences(pkg.name, (lambda v, p, i: self.gen.fact(fn.pkg_provider_preference(pkg.name, v, p, i))))