From 7d5cafef54e56a40d2b533e0b5fb645c6d418548 Mon Sep 17 00:00:00 2001 From: Patrick Lipka Date: Thu, 29 Sep 2022 19:27:42 +0200 Subject: [PATCH] Sort libraries to be installed only after dependencies that are actually present --- lib/sort.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/sort.py b/lib/sort.py index da997fb..f1f3648 100644 --- a/lib/sort.py +++ b/lib/sort.py @@ -25,14 +25,24 @@ def sort_libs_by_dependencies(selected_libs): if len(selected_libs) < 2: return selected_libs + lib_names = [] + for lib in selected_libs: + lib_names.append(lib['name']) + deplist = [] for lib in selected_libs: name = lib['name'] - dependencies = set(lib['dependencies'].split(',')) + # only sort after dependencies that are actually present to avoid cyclic dependencies + deps = [] + for dep in lib['dependencies'].split(','): + if dep in lib_names: + deps.append(dep) + dependencies = set(deps) if dependencies == {''}: dependencies = {} deplist.append([name, dependencies]) sorted_deplist = topological_sort(deplist) + sorted = [] for entry in sorted_deplist: for lib in selected_libs: