You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to use d2 in an environment where I could only install python and npm packages.
Given that, and that I could not find any other solution, I made d2-python-wrapper, a small python wrapper that bundles the d2 binaries.
Now you can use d2 from python like this:
fromd2_pythonimportD2d2=D2()
# Simple diagramwithopen("test.d2", "w") asf:
f.write("x -> y")
# Default SVG outputd2.render("test.d2", "output.svg")
# PDF output with specific themed2.render("test.d2", "output.pdf", format="pdf", theme="1")
The class just wraps the bin, so it works and supports the same as the bin. There is a GitHub Action that gets the bins for each platform (mac, win, linux) from the releases in this repo and publishes it to pip.
Hi,
I wanted to use d2 in an environment where I could only install python and npm packages.
Given that, and that I could not find any other solution, I made d2-python-wrapper, a small python wrapper that bundles the d2 binaries.
Now you can use d2 from python like this:
The class just wraps the bin, so it works and supports the same as the bin. There is a GitHub Action that gets the bins for each platform (mac, win, linux) from the releases in this repo and publishes it to pip.
You can install this using
Here is a short post with more context.
Is this useful enough to add to the "Related" section under "Community plugins"?
The text was updated successfully, but these errors were encountered: