Skip to content

Update pygraphviz - #8694

Merged
rossbar merged 16 commits into
networkx:mainfrom
jarrodmillman:pygraphviz-2
Jun 25, 2026
Merged

rossbar merged 16 commits into
networkx:mainfrom
jarrodmillman:pygraphviz-2

Conversation

@jarrodmillman

@jarrodmillman jarrodmillman commented Jun 11, 2026 •

Copy link
Copy Markdown
Member
The pygraphviz library is now provided via `pip` with wheels that
include the GraphViz binaries. This should make the NetworkX interface
to pygraphviz easier to use for graph layout and rendering.

@jarrodmillman
jarrodmillman marked this pull request as draft June 11, 2026 16:09
@rossbar

rossbar commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

@MridulS we may need your pixi-fu to figure out what needs to be done here!

@jarrodmillman

Copy link
Copy Markdown
Member Author

It is time for me to look into pixi a bit more. :)

@rossbar

rossbar commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

A quick update here - I did some experimentation based on the pixi docs which highlighted the likely cause of the environment resolution error we saw in 8e3a496 . My understanding of the situation is that indeed there were multiple places where a pygraphviz dependency was being specified - once via the optional-dependencies mechanism in pyproject.toml (which pixi reads implicitly to create environments), and once explicitly in the pixi conf in pyproject.toml.

Removing the latter (which included the installation of graphviz from conda) seems to have gotten us past the original environment resolution error.

There are subsequent issues related to the legacy graphviz dependency which I'll continue iterating on here (see f02cddbd and afterwards), but the pixi env resolution issue should be resolved by b5b19a7 and af9cdf0 combined (I didn't want to squash them and force-push since this isn't my PR!)

@rossbar

rossbar commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Okay, this is fully working now! There is one thorny issue re: pydot though...

Pydot still has an implicit dependency on graphviz for rendering. The way things are currently set up, NetworkX has always assumed that having pygraphviz installed meant you also had graphviz available (since it was required to install pygraphviz), and our skipping logic for the pydot rendering/layout tests rely on this assumption. Longer-term, we'll need to figure out how best to update this pattern. My personal vote would be to remove/permanently skip the pydot layout/rendering tests in favor of pygraphviz, which has now definitively solved the graphviz-in-python packaging issue once and for all.

That's a separate discussion though - for this PR, I just went ahead and removed pydot from the optional dependencies so we could focus on the nx_agraph tests.

@rossbar

rossbar commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Here's a comparison of the pygraphviz-based gallery examples: pygraphviz 2.0 (this PR) | pygraphviz 1.14 (main).

@rossbar

rossbar commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

WARNING: I forced push this, so make sure to git reset --hard jarrodmillman/pygraphviz-2 rather than pulling. Apologies for doing so, but it was the cleanest way to get some of the necessary fixes on main into this PR!


I took the liberty of getting this one fully updated in preparation for pygraphviz 2.0.

The biggest thing was to incorporate the pydot conditional test handling added in #8702 , which allowed me to revert some of the pydot-specific hacks I had put in place to get this running (see ce6dbb0 and d80c8ea specifically for the reversion of these hacks).

I also went through and removed what mentions of explicitly needing graphviz installed1, which is no longer the case with pygraphviz 2.0.

This PR (IMO) makes NX fully ready for the pygraphviz 2 release. The only thing that is still required is... pygraphviz 2.0 🙃 . I'll leave as draft now but as soon as pygraphviz 2.0 is out, we can update the pygraphviz==2.0rc4 pin to pygraphviz>=2 and should be good to go!

A final bit of positive circumstantial evidence that things are working as expected, here are the gallery examples that depend on pygraphviz, generated with the pygraphviz rc without graphviz being installed in the CI environment.

Footnotes

  1. Including one in the roadmap(!) Hurray for roadmap progress! ↩

@MridulS MridulS left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the pin.

Let's gooo!

@MridulS
MridulS marked this pull request as ready for review June 25, 2026 18:32

@rossbar rossbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this in the NX community meeting and the consensus was in favor of getting the pygraphviz 2.0 pin in for the networkx 3.7 release... so in this goes!

@rossbar
rossbar merged commit 5a357de into networkx:main Jun 25, 2026
43 checks passed
@dschult dschult added this to the 3.7 milestone Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants