Skip to content

Instantly share code, notes, and snippets.

@tgamblin
Created March 13, 2021 01:35
Show Gist options
  • Save tgamblin/83eba3c6d27f90d9fa3afebfc049ceaf to your computer and use it in GitHub Desktop.
Save tgamblin/83eba3c6d27f90d9fa3afebfc049ceaf to your computer and use it in GitHub Desktop.
Diffing specs by ASP facts in Spack
#!/usr/bin/env spack-python
from pprint import pprint
from spack.spec import Spec
from spack.solver.asp import SpackSolverSetup
specs = [
Spec("openblas +ilp64 +shared").concretized(),
Spec("openblas ~ilp64 +shared").concretized(),
Spec("openblas +ilp64 ~shared").concretized(),
Spec("openblas ~ilp64 ~shared").concretized(),
]
for spec in specs:
print(spec.tree())
def to_tuple(asp_function):
return tuple([asp_function.name, *asp_function.args])
setup = SpackSolverSetup()
def diff(a, b):
a_facts = set(to_tuple(t) for t in setup.spec_clauses(a))
b_facts = set(to_tuple(t) for t in setup.spec_clauses(b))
print(a_facts.difference(b_facts))
print(b_facts.difference(a_facts))
for i in range(len(specs)):
for j in range(len(specs)):
print("diff(%d, %d) ===============================" % (i, j))
diff(specs[i], specs[j])
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment