Alec Bennett wrote:
>> Problem #2: Now when I compile it successfully initializes the
>> device (my webcam), but when it tries to save a file the PIL returns
>> an error: exception.KeyError .jpg.
Alec,
there was a problem with packaging applications with PIL. The bug was
actually in the Python's import machinery (probably introduced in later
Python versions), but still something was not going on correctly. I
corrected the issue and verified that a simple PIL application can now be
built.
Patch attacched, I can't commit it right now for technical problems (I
alerted William about it), but will ASAP.
--
Giovanni Bajo
Index: hooks/hook-PIL.Image.py
===================================================================
--- hooks/hook-PIL.Image.py (revision 276)
+++ hooks/hook-PIL.Image.py (working copy)
@@ -17,6 +17,14 @@
hiddenimports = []
+# FIXME: for a strange bug in Python's import machinery, we need to adjust
+# the module name before proceeding to the PIL import. The name would
+# otherwise be "hooks.hook-PIL.Image", which will then produce this
+# monstruosity:
+# <module 'hooks.hook-PIL.PIL.Image' from
'C:\python24\lib\site-packages\PIL\Image.pyc'>
+#
+__name__ = "hook-image"
+
def install_Image(lis):
import Image
# PIL uses lazy initialization.
Index: hooks/hook-PIL.SpiderImagePlugin.py
===================================================================
--- hooks/hook-PIL.SpiderImagePlugin.py (revision 0)
+++ hooks/hook-PIL.SpiderImagePlugin.py (revision 0)
@@ -0,0 +1,28 @@
+# Copyright (C) 2006, Giovanni Bajo
+# Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises,
Inc.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA
+
+# PIL's SpiderImagePlugin features a tkPhotoImage() method which imports
+# ImageTk (and thus brings the whole Tcl/Tk library in).
+# We cheat a little and remove the ImageTk import: I assume that if people
+# are really using ImageTk in their application, they will also import it
+# directly.
+def hook(mod):
+ for i in range(len(mod.imports)):
+ if mod.imports[i][0] == "ImageTk":
+ del mod.imports[i]
+ break
+ return mod
Property changes on: hooks\hook-PIL.SpiderImagePlugin.py
___________________________________________________________________
Name: svn:eol-style
+ native
Index: doc/CHANGES.txt
===================================================================
--- doc/CHANGES.txt (revision 280)
+++ doc/CHANGES.txt (working copy)
@@ -4,8 +4,12 @@
-------------------------------------
+ Fix bug with user-provided icons disappearing from built executables
when these were compressed with UPX.
-
+ + Fix problems with packaging of applications using PIL (that was broken
+ because of a bug in Python's import machinery, in recent Python
+ versions). Also add a workaround including Tcl/Tk with PIL unless
+ ImageTk is imported.
+
PyInstaller 1.2
---------------
+ Fix a crash when invoking UPX with certain kinds of builds.
_______________________________________________
PyInstaller mailing list
[email protected]
http://lists.hpcf.upr.edu/mailman/listinfo/pyinstaller