Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hooks: rewrite pygraphviz hook #849

Merged
merged 4 commits into from
Jan 7, 2025
Merged

Conversation

rokm
Copy link
Member

@rokm rokm commented Jan 6, 2025

Rewrite pygraphviz hook to fix discovery and collection of graphviz files under various Linux distributions, in Anaconda environments (Windows, Linux, and macOS), and msys2 environments (Windows).

We now discover active graphviz installation on all OSes by looking for dot program in PATH. To find the location of shared libraries and the plugin directory on non-Windows, we now perform binary dependency analysis on the dot executable and look for known graphviz shared libraries in the results.

This improves the discovery on various platforms, and also fixes the issue where system-installed (on Linux) or Homebrew-installed (on macOS) graphviz shared libraries and plugins would end up being collected instead of Anaconda-packaged ones when using Anaconda environment with Anaconda-packaged graphviz.

Supersedes and closes #520.
Closes #705.

@rokm rokm force-pushed the hook-pygraphviz branch from 5d40b8a to 601d0df Compare January 6, 2025 20:27
Add a functional test for `pygraphviz` that tries to use different
`graphviz` programs and output formats, in order to ensure that
`graphviz` programs and plugins are properly collected.

This complements the existing test that ensures that `pygraphviz.AGraph`
resolves the bundled copies of `graphviz` programs, but does not
test their actual use.
@rokm rokm force-pushed the hook-pygraphviz branch from 601d0df to 138d38c Compare January 6, 2025 20:29
Rewrite `pygraphviz` hook to fix discovery and collection of `graphviz`
files under various Linux distributions, in Anaconda environments
(Windows, Linux, and macOS), and msys2 environments (Windows).

We now discover active `graphviz` installation on all OSes by looking
for `dot` program in `PATH`. To find the location of shared libraries
and the plugin directory on non-Windows, we now perform binary
dependency analysis on the `dot` executable and look for known
`graphviz` shared libraries in the results.

This improves the discovery on various platforms, and also fixes the
issue where system-installed (on Linux) or Homebrew-installed
(on macOS) `graphviz` shared libraries and plugins would end up being
collected  instead of Anaconda-packaged ones when using Anaconda
environment with Anaconda-packaged `graphviz`.
@rokm rokm force-pushed the hook-pygraphviz branch from 138d38c to ebf0a53 Compare January 6, 2025 23:25
@rokm rokm marked this pull request as ready for review January 7, 2025 19:05
@rokm
Copy link
Member Author

rokm commented Jan 7, 2025

Tested with:

  • Linux:
    • Fedora with system-provided graphviz, system-provided python & pip-installed pygraphviz.
    • Fedora with Anaconda environment (Anaconda-packaged python, graphviz, pygraphviz). (With system-installed graphviz also available).
    • Debian Bookworm in container (debian:bookworm) with system-provided graphviz, system-provided python & pip-installed pygraphviz.
    • Arch Linux in container (archlinux:latest) with system-provided graphviz, system-provided python & pip installed- pygraphviz.
  • Windows
    • python.org python, official graphviz installer, pip-installed pygraphviz.
    • msys/ming64 environment with msys-packaged python and graphviz, pip-installed pygraphviz.
    • Anaconda environment with Anaconda-packaged python, graphviz, pygraphviz (with official build from first step also being available and its c:\program files\graphviz\bin being in PATH).
  • macOS
    • python.org python, Homebrew-installed graphviz, pip-installed pygraphviz.
    • Anaconda environment with Anaconda-packaged python, graphviz, pygraphviz. (With Homebrew-installed graphviiz also available).

@rokm rokm requested a review from bwoodsend January 7, 2025 19:13
Enable `pygraphviz` tests on linux and macOS; requires installing
`graphviz` via `brew install` (macOS runner) and `apt-get install`
(Ubuntu runner).
@rokm rokm force-pushed the hook-pygraphviz branch 2 times, most recently from e8bdbe7 to 0b1296f Compare January 7, 2025 21:51
On `macos-14` arm64 runners, Homebrew is installed in `/opt/homebrew`
instead of `/usr/local` prefix, and its headers and shared libraries
are not in the default search path. Add them by setting `CPPFLAGS`
and `LDFLAGS`. This is required by `pygraphviz`, which needs to
build its extension and link it against Homebrew-installed `graphviz`.
@rokm rokm force-pushed the hook-pygraphviz branch from 0b1296f to f8a1c2b Compare January 7, 2025 21:52
@rokm rokm merged commit f73f04a into pyinstaller:master Jan 7, 2025
26 checks passed
@rokm rokm deleted the hook-pygraphviz branch January 7, 2025 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PyInstaller: Unable to find '/usr/sbin/neato' when adding binary and data files
2 participants