Sort libraries to be installed only after dependencies that are actually present
This commit is contained in:
parent
6599432c75
commit
7d5cafef54
12
lib/sort.py
12
lib/sort.py
|
@ -25,14 +25,24 @@ def sort_libs_by_dependencies(selected_libs):
|
||||||
if len(selected_libs) < 2:
|
if len(selected_libs) < 2:
|
||||||
return selected_libs
|
return selected_libs
|
||||||
|
|
||||||
|
lib_names = []
|
||||||
|
for lib in selected_libs:
|
||||||
|
lib_names.append(lib['name'])
|
||||||
|
|
||||||
deplist = []
|
deplist = []
|
||||||
for lib in selected_libs:
|
for lib in selected_libs:
|
||||||
name = lib['name']
|
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 == {''}:
|
if dependencies == {''}:
|
||||||
dependencies = {}
|
dependencies = {}
|
||||||
deplist.append([name, dependencies])
|
deplist.append([name, dependencies])
|
||||||
sorted_deplist = topological_sort(deplist)
|
sorted_deplist = topological_sort(deplist)
|
||||||
|
|
||||||
sorted = []
|
sorted = []
|
||||||
for entry in sorted_deplist:
|
for entry in sorted_deplist:
|
||||||
for lib in selected_libs:
|
for lib in selected_libs:
|
||||||
|
|
Loading…
Reference in New Issue