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: