From b3b6fc89a3822996dd03618dc8c742af480eb118 Mon Sep 17 00:00:00 2001 From: Ole-Morten Duesund Date: Tue, 25 Aug 2026 15:31:30 +0200 Subject: [PATCH] conandeps: dedicated "level" column for the level of indirection Show the hop count from the consumer as its own numeric column in both the text and the HTML dependency table instead of folding it into the kind cell as "indirect (N)". Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01EYNdaGDrpaqDyT8QtrTQbM --- README.md | 19 ++++++++++--------- conandeps.py | 11 +++++------ tests/test_conandeps.py | 7 +++++-- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index a6501e0..f221bf4 100644 --- a/README.md +++ b/README.md @@ -92,12 +92,12 @@ profile: arch=x86_64, compiler=gcc, compiler.libcxx=libstdc++11, compiler.versio Dependencies (4) and binary availability -package kind ctx Release Debug RelWithDebInfo --------------------------------------------------------------- -MyDepA/1.0 direct host knor knor knor -MyDepB/1.0 direct host knor knor knor -boost/1.8 indirect (2) host knor knor knor -Zigma/1.0 indirect (2) host knor knor MISSING +package kind level ctx Release Debug RelWithDebInfo +----------------------------------------------------------------- +MyDepA/1.0 direct 1 host knor knor knor +MyDepB/1.0 direct 1 host knor knor knor +boost/1.8 indirect 2 host knor knor knor +Zigma/1.0 indirect 2 host knor knor MISSING Missing binaries (1) @@ -128,9 +128,10 @@ produces colour codes unless you pass `--color always`. The HTML report uses the same colour coding. Reading the table: rows are sorted with direct dependencies first -(alphabetically), then indirect ones by increasing level of indirection – -`indirect (2)` is required by a direct dependency, `indirect (3)` by one of -those, and so on (shortest path counts). +(alphabetically), then indirect ones by increasing level of indirection. The +`level` column is the number of hops from your conanfile: 1 is direct, 2 is +required by a direct dependency, 3 by one of those, and so on (shortest path +counts). The HTML report has the same column. * `knor` (a remote name) – the remote has a binary for the package_id your diff --git a/conandeps.py b/conandeps.py index e53352d..3de775d 100755 --- a/conandeps.py +++ b/conandeps.py @@ -521,8 +521,7 @@ def _override_kind(o: Override) -> str: def _kind(dep: Dep) -> str: - """'direct', or 'indirect (N)' where N is the number of hops from the consumer.""" - return "direct" if dep.direct else "indirect (%d)" % dep.depth + return "direct" if dep.direct else "indirect" def render_text(report: Report, color: bool = False) -> str: @@ -538,11 +537,11 @@ def render_text(report: Report, color: bool = False) -> str: w(pal.bold("Dependencies (%d) and binary availability" % len(report.deps))) w("") rows = [ - [dep.ref, _kind(dep), dep.context] + [dep.ref, _kind(dep), str(dep.depth), dep.context] + [_cell(*dep.binaries[bt], pal) for bt in report.build_types] for dep in report.deps.values() ] - out.extend(_table(["package", "kind", "ctx"] + list(report.build_types), rows, pal)) + out.extend(_table(["package", "kind", "level", "ctx"] + list(report.build_types), rows, pal)) w("") # ---- missing binaries ------------------------------------------------ @@ -641,14 +640,14 @@ def render_html(report: Report) -> str: w("

Dependencies (%d) and binary availability

" % len(report.deps)) rows = [] for dep in report.deps.values(): - row = [e(dep.ref), e(_kind(dep)), e(dep.context)] + row = [e(dep.ref), e(_kind(dep)), str(dep.depth), e(dep.context)] for bt in report.build_types: status, pid, remote = dep.binaries[bt] cls = {"Remote": "ok", "Missing": "missing", "CacheOnly": "cacheonly"}.get(status, "na") text = e(_cell(status, pid, remote, _Palette(False))) row.append('%s' % (cls, e(pid), text)) rows.append(row) - w(_html_table(["package", "kind", "context"] + list(report.build_types), rows)) + w(_html_table(["package", "kind", "level", "context"] + list(report.build_types), rows)) # ---- missing binaries ------------------------------------------------ problems = report.problems() diff --git a/tests/test_conandeps.py b/tests/test_conandeps.py index 5e93efc..36d846b 100644 --- a/tests/test_conandeps.py +++ b/tests/test_conandeps.py @@ -243,8 +243,11 @@ def test_sorted_by_level_of_indirection(report): ("libdeep/1.0", 3), ] text = conandeps.render_text(report) - assert re.search(r"libbar/1\.1\s+indirect \(2\)", text) - assert re.search(r"libdeep/1\.0\s+indirect \(3\)", text) + assert re.search(r"libbar/1\.1\s+indirect\s+2\s+host", text) + assert re.search(r"libdeep/1\.0\s+indirect\s+3\s+host", text) + page = conandeps.render_html(report) + assert "level" in page + assert "libdeep/1.0indirect3host" in page def test_missing_binaries(report):