'Given a list of candidate virtual and external packages, try to
find one that is most ABI compatible.'

def choose_virtual_or_external(self, spec):

    candidates = self._valid_virtuals_and_externals(spec)
    if (not candidates):
        return candidates
    abi_exemplar = find_spec(spec, (lambda x: x.compiler), spec.root)
    return sorted(candidates, reverse=True, key=(lambda spec: (spack.abi.compatible(spec, abi_exemplar, loose=True), spack.abi.compatible(spec, abi_exemplar))))
