def _compute_root_packages(self, pool, install_map, update_map): """ Look at the root packages in the given maps. Root packages are packages which are not dependencies of other packages. """ packages = OrderedDict(install_map) packages.update(update_map) roots = packages.copy() for package_id, operation in packages.items(): package = operation.package if package_id not in roots: continue for dependency in package.dependencies: candidates = pool.what_provides( Requirement.from_legacy_requirement_string(dependency) ) for candidate in candidates: candidate_id = pool.package_id(candidate) roots.pop(candidate_id, None) return roots
def _compute_root_packages(self, pool, install_map, update_map): """ Look at the root packages in the given maps. Root packages are packages which are not dependencies of other packages. """ packages = OrderedDict(install_map) packages.update(update_map) roots = packages.copy() for package_id, operation in packages.items(): package = operation.package if package_id not in roots: continue for dependency in package.dependencies: candidates = pool.what_provides( Requirement.from_legacy_requirement_string(dependency)) for candidate in candidates: candidate_id = pool.package_id(candidate) roots.pop(candidate_id, None) return roots
def _compute_transaction_from_maps(self, pool, install_map, update_map, remove_map): operations = self._compute_root_packages(pool, install_map, update_map) queue = [operation.package for operation in operations.values()] visited_ids = set() # Install/update packages, starting from the ones which do not # depend on anything else (using topological sort) # FIXME: better implementation while len(queue) > 0: package = queue.pop() package_id = pool.package_id(package) if package_id in visited_ids: if package_id in install_map: operation = install_map.pop(package_id) self.install(operation.package) if package_id in update_map: operation = update_map.pop(package_id) self.update(operation.source, operation.package) else: queue.append(package) # We use sorted for determinism for dependency in sorted(package.dependencies): package_requirement = \ Requirement.from_legacy_requirement_string(dependency) candidates = pool.what_provides(package_requirement) queue.extend(candidates) visited_ids.add(package_id) for operation in remove_map.values(): self.remove(operation.package)
def _compute_transaction_from_maps(self, pool, install_map, update_map, remove_map): operations = self._compute_root_packages(pool, install_map, update_map) queue = [operation.package for operation in operations.values()] visited_ids = set() # Install/update packages, starting from the ones which do not # depend on anything else (using topological sort) # FIXME: better implementation while len(queue) > 0: package = queue.pop() package_id = pool.package_id(package) if package_id in visited_ids: if package_id in install_map: operation = install_map.pop(package_id) self.install(operation.package) if package_id in update_map: operation = update_map.pop(package_id) self.update(operation.source, operation.package) else: queue.append(package) # We use sorted for determinism for dependency in sorted(package.dependencies): package_requirement = \ Requirement.from_legacy_requirement_string(dependency) candidates = pool.what_provides(package_requirement) queue.extend(candidates) visited_ids.add(package_id) for operation in remove_map.values(): self.remove(operation.package)