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

Fix msys2 dll paths in GdkPixbuf loaders.cache gen #7842

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.