def virtual_preferences(self, pkg_name, func):
    "Call func(vspec, provider, i) for each of pkg's provider prefs."
    config = spack.config.get('packages')
    pkg_prefs = config.get(pkg_name, {}).get('providers', {})
    for (vspec, providers) in pkg_prefs.items():
        if (vspec not in self.possible_virtuals):
            continue
        for (i, provider) in enumerate(providers):
            provider_name = spack.spec.Spec(provider).name
            func(vspec, provider_name, i)
Call func(vspec, provider, i) for each of pkg's provider prefs.
def virtual_preferences(self, pkg_name, func):
    
    config = spack.config.get('packages')
    pkg_prefs = config.get(pkg_name, {}).get('providers', {})
    for (vspec, providers) in pkg_prefs.items():
        if (vspec not in self.possible_virtuals):
            continue
        for (i, provider) in enumerate(providers):
            provider_name = spack.spec.Spec(provider).name
            func(vspec, provider_name, i)