Correct way to write a hook for pygraphviz (which has hidden dependencies to graphviz)

29 views
Skip to first unread message

Krister Swenson

unread,
Jun 16, 2020, 4:07:13 AM6/16/20
to PyInstaller
Hello,

I'm trying to package an app that depends heavily on graphviz and pygraphviz. The dependencies do not get automatically pulled in as there is to pygraphviz hook. I would like to write one but need some guidance.

I stared with a simple hook to include the graphviz executables along with the dynamic libararies (I'm on macos and linux, but will include only the macos lines here)...

binaries=[
          ('/usr/local/bin/dot', '.'),
          ('/usr/local/bin/nop', '.'),         #There are others to include (e.g. neato).
          ('/usr/local/Cellar/graphviz/*/lib/*.dylib', '.'),
          ('/usr/local/Cellar/graphviz/*/lib/graphviz/*.dylib', 'graphviz'),
         ] #+ libs

datas=[
       ('/usr/local/Cellar/graphviz/*/lib/graphviz/config6', 'graphviz'),
      ]

This is not sufficient, since graphviz depends on packages like libtool (that's the name in brew) so I add `          ('/usr/local/Cellar/libtool/*/lib/*.dylib', '.'),` to the list of binaries. Yet there are a ton of dependencies for graphviz:

 => brew deps graphviz
cairo
fontconfig
freetype
fribidi
gd
gdbm
gettext
glib
graphite2
gts
harfbuzz
icu4c
jasper
jpeg
libffi
libpng
libtiff
libtool
lzo
netpbm
openssl@1.1
pango
pcre
pixman
python
readline
sqlite
webp
xz

I assume that there is a function in pyinstaller that would recursively include dynamic libraries but I haven't found it. For example, the function `depend.bindepend.findSystemLibrary`, which I assume would be used by such a recursive function is only called in gi.py, and nowhere else. Are we expected to write this function ourselves?

Thanks for the help!

Krister Swenson

unread,
Jun 16, 2020, 12:09:30 PM6/16/20
to PyInstaller
It turns out that pyinstaller does try to recursively resolve shared library dependencies. In this case, there are dependencies that are not found. When I include those manually, AND WITHOUT WILDCARDS, then pyinstaller will follow recursively the dependencies. So the wildcards in the binaries is the main problem keeping the .spec file from working.

I'm working on a hook for pygraphviz  here: https://github.com/pyinstaller/pyinstaller/issues/4938

kms
Reply all
Reply to author
Forward
0 new messages