Skip to content

Commit

Permalink
Fix msys2 dll paths in GdkPixbuf loaders.cache gen (#7842)
Browse files Browse the repository at this point in the history
  • Loading branch information
coolcatco888 authored and bwoodsend committed Aug 26, 2023
1 parent b55f92c commit 68eeee2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion PyInstaller/hooks/hook-gi.repository.GdkPixbuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _collect_loaders(libdir):

# Sometimes the loaders are stored in a different directory from the library (msys2)
if not loader_libs:
pattern = os.path.join(libdir, '..', 'lib', LOADERS_PATH, lib_ext)
pattern = os.path.abspath(os.path.join(libdir, '..', 'lib', LOADERS_PATH, lib_ext))
for f in glob.glob(pattern):
loader_libs.append(f)

Expand Down Expand Up @@ -89,6 +89,9 @@ def _generate_loader_cache(gdk_pixbuf_query_loaders, libdir, loader_libs):
win_prefix = '"' + '\\\\'.join(['lib', 'gdk-pixbuf-2.0', '2.10.0'])
win_plen = len(win_prefix)

msys2_prefix = '"' + os.path.abspath(os.path.join(libdir, '..', 'lib', 'gdk-pixbuf-2.0', '2.10.0'))
msys2_plen = len(msys2_prefix)

# For each line in the updated loader cache...
for line in cachedata.splitlines():
if line.startswith('#'):
Expand All @@ -97,6 +100,8 @@ def _generate_loader_cache(gdk_pixbuf_query_loaders, libdir, loader_libs):
line = '"@executable_path/' + LOADER_CACHE_DEST_PATH + line[plen:]
elif line.startswith(win_prefix):
line = '"' + LOADER_CACHE_DEST_PATH.replace('/', '\\\\') + line[win_plen:]
elif line.startswith(msys2_prefix):
line = ('"' + LOADER_CACHE_DEST_PATH + line[msys2_plen:]).replace('/', '\\\\')
output_lines.append(line)

return '\n'.join(output_lines)
Expand Down
6 changes: 6 additions & 0 deletions news/7842.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(Windows) Fixed bug where GdkPixbuf loaders.cache dll paths are absolute
paths (eg. ``C:/tools/msys64/mingw64/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.dll``)
and not relative paths (eg. ``lib\\gdk-pixbuf\\loaders\\libpixbufloader-png.dll``)
when the file is generated in the msys2/mingw64 environment. This results in
the program crashing when run on another Windows machine because it cannot find the
GdkPixbuf loader dlls.

0 comments on commit 68eeee2

Please sign in to comment.