code: def finalise(self):
          
          assert(self._is_solved())
          g = self._get_minimal_graph()
          scopes = dict((x.package_name, x) for x in self.scopes
                        if not x.package_request.conflict)
  
          # check for cyclic dependencies
          fam_cycle = find_cycle(g)
          if fam_cycle:
              cycle = []
              for fam in fam_cycle:
                  scope = scopes[fam]
                  variant = scope._get_solved_variant()
                  stmt = VersionedObject.construct(fam, variant.version)
                  cycle.append(stmt)
  
              phase = copy.copy(self)
              phase.scopes = scopes.values()
              phase.failure_reason = Cycle(cycle)
              phase.status = SolverStatus.cyclic
              return phase
  
          # reorder wrt dependencies, keeping original request order where possible
          fams = [x.name for x in self.solver.request_list]
          ordered_fams = _get_dependency_order(g, fams)
  
          scopes_ = []
          for fam in ordered_fams:
              scope = scopes[fam]
              if not scope.package_request.conflict:
                  scopes_.append(scope)
  
          phase = copy.copy(self)
          phase.scopes = scopes_
          return phase
docs: Remove conflict requests, detect cyclic dependencies, and reorder
          packages wrt dependency and then request order.
  
          Returns:
              A new copy of the phase with conflict requests removed and packages
              correctly ordered; or, if cyclic dependencies were detected, a new
              phase marked as cyclic.