I dove into the mess and came up with a working solution. First, I generated a local copy of loaders.cache with::
gdk-pixbuf-query-loaders > loaders.cache
Then, I edited loaders.cache, removing the long path names. For example, I changed:
"/usr/local/Cellar/gdk-pixbuf/2.30.8/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-ani.so"
to:
"libpixbufloader-ani.so"
and so on.
Then, I created an rthook file called pixbuf_rthook.py to change the GDK_PIXBUF_MODULE_FILE environment variable on start-up::
> import os
>
> os.environ['GDK_PIXBUF_MODULE_FILE'] = os.environ['PWD'] + '/loaders.cache'
Finally, I added the rthook, libpixbufloaders*, and loaders.cache to my .spec file. It now looks like this::
> # -*- mode: python -*-
> a = Analysis(['pixbuf.py'],
> pathex=['/Users/apple/Downloads/test_pyinstall2'],
> hiddenimports=['glib'],
> hookspath=None,
> runtime_hooks=['pixbuf_rthook.py'])
> pyz = PYZ(a.pure)
>
> more_binaries = []
> pixbuf_dir = '/usr/local/lib/gdk-pixbuf-2.0/2.10.0/loaders'
> for pixbuf_type in os.listdir(pixbuf_dir):
> if pixbuf_type.endswith('.so'):
> more_binaries.append((pixbuf_type, os.path.join(pixbuf_dir, pixbuf_type), 'BINARY'))
>
> exe = EXE(pyz,
> a.scripts,
> exclude_binaries=True,
> name='pixbuf',
> debug=False,
> strip=None,
> upx=True,
> console=True )
> coll = COLLECT(exe, [('loaders.cache', './loaders.cache', 'DATA')],
> a.binaries + more_binaries,
> a.zipfiles,
> a.datas,
> strip=None,
> upx=True,
> name='pixbuf')
This fixed the errors and now gtk.gdk.pixbuf_new_from_file works.
The changes to my main application were more extensive, because pango had a similar cache-type file called pango.modules and pangox.aliases which I worked in with similar methods. If anyone would like to see the adjustments for the full application, let me know, and I can post it here. If macports is equally as messy with gtk and pyinstaller, it probably makes sense to adjust the osx gtk hook and rthooks in PyInstaller itself so others can benefit from these findings.