docs icon indicating copy to clipboard operation
docs copied to clipboard

[question] How to exclude tool_requires from graph info output

Open nicosmd opened this issue 1 year ago • 5 comments

What is your question?

Hey,

I would like to create a graph visualization using graph info .. --format=dot ... We have defined some tool_requires in the host profile to apply them to the every package. The resulting graph visualization is now really a mess since every package is pointing to those tool_requires.

Is there a way to hide tool_requires for the graph output?

Thank you very much!

Have you read the CONTRIBUTING guide?

  • [X] I've read the CONTRIBUTING guide

nicosmd avatar Feb 22 '24 08:02 nicosmd

Hi @nicosmd

The templates for html and dot graphs are customizable. I think this feature is still not properly documented (just some hints in https://docs.conan.io/2/reference/commands/graph/info.html for html), but mostly:

  • The path is os.path.join(conan_api.cache_folder, "templates", "graph.dot")
  • Every node in the graph has the is_build_requires, so {% if node.is_build_requires %} can be used to filter if a node is in the build context or not

memsharded avatar Feb 22 '24 09:02 memsharded

Thank you very much! That's great to know and exactly what I need.

nicosmd avatar Feb 22 '24 09:02 nicosmd

Just in case others came a cross this issue, this is the content of the os.path.join(conan_api.cache_folder, "templates", "graph.dot") file I've used in order to filter build dependencies:

digraph {
    {%- for src, dst in graph.edges %}
        {% if not dst.is_build_requires %}
            "{{ src.label }}" -> "{{ dst.label }}"
        {% endif %}
    {%- endfor %}
}

nicosmd avatar Feb 22 '24 10:02 nicosmd

re-opening to add a bit more of docs

memsharded avatar Feb 22 '24 10:02 memsharded

FYI; the --format=html output has been greatly improved in 2.2, now it includes filters to hide build and test-requires, to group them, and many other improvements.

memsharded avatar Mar 21 '24 10:03 memsharded