From 78911d6077ba35a18771b385c76a2d5eabadec40 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 31 Dec 2013 10:20:33 +0530 Subject: [PATCH] Windows 64bit build: Fix corrupted images in MOBI files causing crash. Fixes #1264534 [calibre-parallel has stopped working](https://bugs.launchpad.net/calibre/+bug/1264534) Loads the PIL C extensions from the file system as they apparently use exceptions that cause crash with MemoryModule --- setup/installer/windows/freeze.py | 5 ++++- setup/installer/windows/notes.rst | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/setup/installer/windows/freeze.py b/setup/installer/windows/freeze.py index 2c3662c1c8..b52b375217 100644 --- a/setup/installer/windows/freeze.py +++ b/setup/installer/windows/freeze.py @@ -671,7 +671,10 @@ class Win32Freeze(Command, WixMixIn): sp = self.j(self.lib_dir, 'site-packages') # Special handling for PIL and pywin32 handled = set(['PIL.pth', 'pywin32.pth', 'PIL', 'win32']) - if not is64bit: + if is64bit: + # PIL can raise exceptions, which cause crashes on 64bit + shutil.copytree(self.j(sp, 'PIL'), self.j(self.dll_dir, 'PIL')) + else: self.add_to_zipfile(zf, 'PIL', sp) base = self.j(sp, 'win32', 'lib') for x in os.listdir(base): diff --git a/setup/installer/windows/notes.rst b/setup/installer/windows/notes.rst index 30f462ecb8..7d4f315dce 100644 --- a/setup/installer/windows/notes.rst +++ b/setup/installer/windows/notes.rst @@ -414,6 +414,13 @@ Build and install with:: Note that the lcms module will not be built. PIL requires lcms-1.x but only lcms-2.x can be compiled as a 64 bit library. +Pillow >= 2.2 installs itself as a .egg file. calibre needs it to be a PIL +directory. Extract the PIL directory as follows: + cd /cygdrive/c/Python27/Lib/site-packages + mkdir p && cd p + unzip ../Pillow-*.egg + cd .. && rm Pillow-*.egg && mv p/PIL . && chmod +x PIL/*.pyd + Test it on the target system with calibre-debug -c "from PIL import Image; import _imaging, _imagingmath, _imagingft"