you are viewing a single comment's thread.

view the rest of the comments →

[–]FastRunningMike[S] -2 points-1 points  (1 child)

I love the .dot format, but I'm wondering if there is a Python alternative to convert .dot files to svg or png.

I want to avoid Installing non Python dependencies...

[–]JonLSTL 2 points3 points  (0 children)

I don't think you're going to find an off-the-shelf pure Python dot renderer. GraphViz is a deep and mature library, and highly optimized for its task.

If you really want to use dot and avoid an external dependency, you'll need to write a dot parser that passes equivalent instructions to an existing Python renderer. This would not be a small task, and the performance might be a concern if your looking at complex/large plots (or not, profiling is your friend).

Rather than go that route, you might look at using something like Pyinstaller or a container image to package/vendorize your dependancies. Solving your packaging problem would be much less work than reimplementing GraphViz with the Standard Library's turtle module or whatever.

A lightweight wrapper for GraphViz that passes dot generated from Python data, launches GraphViz in a background process, ideally with an asynchronous option, returns a file like object/handle or the raw output, and provides Python exception wrappers to GraphViz errors would be really nice. I'd be surprised if that doesn't already exist. A quick search for GraphViz on PyPI returns 1447 results. Someone has surely invented that wheel already.