diff --git a/src/ifcpatch/ifcpatch/recipes/Optimise.py b/src/ifcpatch/ifcpatch/recipes/Optimise.py index 581a89c643..3f3eb8a6fa 100644 --- a/src/ifcpatch/ifcpatch/recipes/Optimise.py +++ b/src/ifcpatch/ifcpatch/recipes/Optimise.py @@ -25,18 +25,18 @@ def _toposort(graph: dict[int, set[int]], logger: logging.Logger) -> list[int]: """Flatten a dependency graph of entity ids into dependency order. Uses igraph's C-backed topological sort when available, otherwise falls - back to the pure python toposort package with a warning. + back to the stdlib graphlib topological sort with a warning. """ try: import igraph except ImportError: logger.warning( - "igraph is not installed, falling back to the slower pure python toposort. " + "igraph is not installed, falling back to the slower stdlib graphlib. " "Install python-igraph for better performance." ) - from toposort import toposort_flatten + from graphlib import TopologicalSorter - return toposort_flatten(graph) + return list(TopologicalSorter(graph).static_order()) ids = list(graph) index = {id_: i for i, id_ in enumerate(ids)} diff --git a/src/ifcpatch/pyproject.toml b/src/ifcpatch/pyproject.toml index 22cf2ec3c5..e9f77a989f 100644 --- a/src/ifcpatch/pyproject.toml +++ b/src/ifcpatch/pyproject.toml @@ -15,7 +15,7 @@ classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", ] -dependencies = ["ifcopenshell", "toposort", "numpy"] +dependencies = ["ifcopenshell", "numpy"] [project.optional-dependencies] advanced = [