diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index 1716890887..93e9a87583 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -1117,11 +1117,8 @@ def __init__(self, tests=False): self.reusable_and_possible = ConcreteSpecsByHash() - # id for dummy variables - self._condition_id_counter = itertools.count() - self._trigger_id_counter = itertools.count() + self._id_counter = itertools.count() self._trigger_cache = collections.defaultdict(dict) - self._effect_id_counter = itertools.count() self._effect_cache = collections.defaultdict(dict) # Caches to optimize the setup phase of the solver @@ -1517,7 +1514,7 @@ def condition( # In this way, if a condition can't be emitted but the exception is handled in the caller, # we won't emit partial facts. - condition_id = next(self._condition_id_counter) + condition_id = next(self._id_counter) self.gen.fact(fn.pkg_fact(named_cond.name, fn.condition(condition_id))) self.gen.fact(fn.condition_reason(condition_id, msg)) @@ -1525,7 +1522,7 @@ def condition( named_cond_key = (str(named_cond), transform_required) if named_cond_key not in cache: - trigger_id = next(self._trigger_id_counter) + trigger_id = next(self._id_counter) requirements = self.spec_clauses(named_cond, body=True, required_from=name) if transform_required: @@ -1541,7 +1538,7 @@ def condition( cache = self._effect_cache[named_cond.name] imposed_spec_key = (str(imposed_spec), transform_imposed) if imposed_spec_key not in cache: - effect_id = next(self._effect_id_counter) + effect_id = next(self._id_counter) requirements = self.spec_clauses(imposed_spec, body=False, required_from=name) if transform_imposed: @@ -2549,12 +2546,8 @@ def setup( reuse: list of concrete specs that can be reused allow_deprecated: if True adds deprecated versions into the solve """ - self._condition_id_counter = itertools.count() - - # preliminary checks check_packages_exist(specs) - # get list of all possible dependencies self.possible_virtuals = set(x.name for x in specs if x.virtual) node_counter = _create_counter(specs, tests=self.tests) @@ -2674,8 +2667,8 @@ def setup( def literal_specs(self, specs): for spec in specs: self.gen.h2("Spec: %s" % str(spec)) - condition_id = next(self._condition_id_counter) - trigger_id = next(self._trigger_id_counter) + condition_id = next(self._id_counter) + trigger_id = next(self._id_counter) # Special condition triggered by "literal_solved" self.gen.fact(fn.literal(trigger_id)) @@ -2689,7 +2682,7 @@ def literal_specs(self, specs): "literal specs have different requirements. clear cache before computing literals" ) assert imposed_spec_key not in cache, msg - effect_id = next(self._effect_id_counter) + effect_id = next(self._id_counter) requirements = self.spec_clauses(spec) root_name = spec.name for clause in requirements: