cmds.projects.CmdBuild: Sort build order

The build order printed by projects build is not reproducible:
calculate_order() picks the next module by iterating all_deps, a set, so
the order among modules that are ready at the same time depends on the hash
seed of the Python process, and two runs of the same invocation can print
different orders.

Select the next module from the sorted set instead. The order stays
topologically valid, and is now identical across runs and hash seeds. Sort
the unresolvable-dependency error message the same way, so that it is
stable, too.

Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.86.1
This commit is contained in:
Jan Lindemann 2026-09-22 06:40:51 +02:00
commit 7af9a705d7
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -162,15 +162,16 @@ class CmdBuild(Cmd): # export
log(DEBUG, f'--- Adding dependency tree of module "{m}"')
add_dep_tree(m, dep_flavours, dep_tree, all_deps)
while len(all_deps):
# Find any leaf
for d in all_deps:
# Find any leaf, deterministically: sorted, so that the
# order is reproducible across runs
for d in sorted(all_deps):
# Dependency d doesn't have dependencies itself
if not len(dep_tree[d]):
break # found
else: # no Leaf found
raise Exception(
'Fatal: Dependencies between these modules are unresolvable: '
', '.join(all_deps)
', '.join(sorted(all_deps))
)
order.append(d) # do it
# bookkeep it