pypa / pipenv

Python Development Workflow for Humans.
https://pipenv.pypa.io
MIT License
24.83k stars 1.87k forks source link

Generate graph in Dot graph format #3543

Open ghost opened 5 years ago

ghost commented 5 years ago

Is your feature request related to a problem?

No.

Describe the solution you'd like

pipenv graph --dot should generate a Dot file syntax representation of the dependency graph, ideally with the entries listed in the Pipfile highlighted in some way.

Describe alternatives you've considered

This ugly command group converts a flat JSON representation from Pipenv to Dot:

{ \
    echo 'digraph "Pipenv dependency graph" {' \
    && pipenv graph --json | jq --raw-output '.[] | "\"" + .package.package_name + "\";", "\"" + .package.package_name + "\" -> \"" + .dependencies[].package_name + "\";"' \
    && echo "}"; \
}

This can be piped to for example dot -Tsvg to create an SVG representation of the graph.

The package names on separate lines is necessary to list packages without any dependencies or reverse dependencies.

techalchemy commented 5 years ago

I'm not totally convinced about implementing this, but i think pipdeptree might already support it so we may be able to leverage that

cmatsuoka commented 5 years ago

I just tested it with pipdeptree.py --graph-output dot and it worked quite well.

matteius commented 1 year ago

Someone could add a --dot flag to the graph command if its important to have.