Skip to content

Commit 1754b87

Browse files
committed
Fix the finding of pixbuf loaders on Windows
1 parent 621a4f2 commit 1754b87

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

.appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ install:
2424
# Add %PYTHON% to the path for libffi-7.dll
2525
- set PATH=%PYTHON%;C:\msys64\mingw64\lib;%PATH%
2626
build_script:
27-
- "%PYTHON%\\python.exe setup.py build bdist_wheel"
27+
- "%PYTHON%\\python.exe -u setup.py build bdist_wheel"
2828
# Simplify PATH so as to test binary distribution
2929
- set PATH=C:\WINDOWS\system32;C:\WINDOWS
3030
test_script:
@@ -35,7 +35,7 @@ deploy:
3535
provider: GitHub
3636
auth_token:
3737
secure: QimY++/91urL/oMJL/q2zYFqc1C7747HguEaIbPQovtC3zG8CK+TiCmFOCXy1D6e
38-
artifact: "/dist/*.whl"
38+
artifact: "dist/*.whl"
3939
draft: false
4040
prerelease: false
4141
force_update: true

setup.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ def run(self):
5252
import subprocess as sp
5353
from typing import List, Optional
5454

55-
dependencies = ["pango", "cmake", "gtk2", "glib2", "tk", "toolchain"]
55+
dependencies = ["pango", "cmake", "gtk2", "glib2", "tk", "toolchain", "libffi"]
5656

5757
for dep in dependencies:
5858
printf("Installing dependency {}...".format(dep), end=" ")
59-
sp.call(["pacman", "--needed", "--noconfirm", "-S", "mingw-w64-x86_64-{}".format(dep)], stdout=sp.PIPE)
59+
sp.call(["pacman", "--needed", "--noconfirm", "-S", "mingw-w64-x86_64-{}".format(dep)],
60+
stdout=sp.PIPE, stderr=sp.PIPE)
6061
printf("Done.")
6162
sp.call(["cmake", ".", "-G", "MinGW Makefiles"])
6263
sp.call(["mingw32-make"])
@@ -157,12 +158,23 @@ def copy_to_target(self, target: str):
157158
shutil.copyfile(p, os.path.join(target, os.path.basename(p)))
158159

159160
specials={
160-
"libpixmap.dll": "/lib/gtk-2.0/2.10.0/engines/",
161-
"libwimp.dll": "/lib/gtk-2.0/2.10.0/engines/",
162-
"loaders.cache": "/lib/gdk-pixbuf-2.0/2.10.0/"} # loaders.cache is used to specify abspaths to the loaders
161+
"libpixmap.dll": "lib/gtk-2.0/2.10.0/engines/",
162+
"libwimp.dll": "lib/gtk-2.0/2.10.0/engines/",
163+
"loaders.cache": "lib/gdk-pixbuf-2.0/2.10.0/"} # loaders.cache is used to specify abspaths to the loaders
163164
specials.update({"libpixbufloader-{}.dll".format(fmt): "/lib/gdk-pixbuf-2.0/2.10.0/loaders/"
164165
for fmt in ["ani", "bmp", "gif", "icns", "ico", "jpeg", "png", "pnm", "qtif", "svg", "tga", "tiff", "xbm", "xpm"]})
165166
DependencyWalker("libgttk.dll", specials=specials).copy_to_target("gttk")
167+
168+
# If loaders.cache is not found, it must be generated
169+
cache_file = os.path.join("gttk", specials["loaders.cache"], "loaders.cache")
170+
if not os.path.exists(cache_file) or os.path.getsize(cache_file) < 1024: # Minimum expected file size
171+
print("Creating loaders.cache file...")
172+
with open("loaders.cache", "wb") as fo:
173+
sp.call(["gdk-pixbuf-query-loaders"], stdout=fo)
174+
shutil.copyfile("loaders.cache", cache_file)
175+
with open(cache_file) as fi:
176+
print("gdk-pixbuf-query-loaders gave {} lines of output".format(len(fi.readlines())))
177+
166178
kwargs = {"package_data": {"gttk": ["*.dll", "pkgIndex.tcl", "gttk.tcl"] + ["{}/{}".format(dir.strip("/"), base) for base, dir in specials.items()]}}
167179

168180
else:

0 commit comments

Comments
 (0)