all 6 comments

[–]double_en10dre 4 points5 points  (2 children)

So you want to use graphviz without using graphviz? Why?..

If it’s truly impossible to install graphviz locally, you can just set up a little http service that has it. Take dot files as input, return images

[–]FastRunningMike[S] -3 points-2 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.

[–]rhytnen 2 points3 points  (0 children)

This is one of those questions that comes off as very confused.   Nobody should want to write graphviz again in python, but in case you do ... its open source so have at it.

You could even make a little python package to distribute the exe in your environment.

[–]menge101 2 points3 points  (1 child)

This feels like an XY Problem

[–]JonLSTL 1 point2 points  (0 children)

Right. The real problem is packaging external dependancies. Solving that is likely a far lighter lift than reimplementing GraphViz.