Commits

Ronald Oussoren committed 89788e3

Actually make it possible to use Pillow, fixes #108

  • Participants
  • Parent commits be78bb0
  • Branches branch-0.7

Comments (0)

Files changed (2)

File py2app/recipes/PIL/__init__.py

     for folder in sys.path:
         if not isinstance(folder, basestring):
             continue
-        folder = os.path.realpath(folder)
-        if (not os.path.isdir(folder)) or (folder in visited):
-            continue
-        for fn in os.listdir(folder):
-            if not fn.endswith('ImagePlugin.py'):
+
+        for extra in ('', 'PIL'):
+            folder = os.path.realpath(os.path.join(folder, extra))
+            if (not os.path.isdir(folder)) or (folder in visited):
                 continue
-            mod, ext = os.path.splitext(fn)
-            try:
-                sys.path.insert(0, folder)
-                imp_find_module(mod)
-                del sys.path[0]
-            except ImportError as exc:
-                pass
-            else:
-                plugins.add(mod)
+            for fn in os.listdir(folder):
+                if not fn.endswith('ImagePlugin.py'):
+                    continue
+
+                mod, ext = os.path.splitext(fn)
+                try:
+                    sys.path.insert(0, folder)
+                    imp_find_module(mod)
+                    del sys.path[0]
+                except ImportError:
+                    pass
+                else:
+                    plugins.add(mod)
         visited.add(folder)
     s = StringIO('_recipes_pil_prescript(%r)\n' % list(plugins))
     for plugin in plugins:
         if have_PIL:
+            mf.implyNodeReference(m, 'PIL.' + plugin)
+        else:
             mf.implyNodeReference(m, plugin)
-        else:
-            mf.implyNodeReference(m, 'PIL.' + plugin)
+
     mf.removeReference(m, 'FixTk')
     # Since Imaging-1.1.5, SpiderImagePlugin imports ImageTk conditionally.
     # This is not ever used unless the user is explicitly using Tk elsewhere.

File py2app/recipes/PIL/prescript.py

         if Image._initialized >= 2:
             return
 
+        if have_PIL:
+            try:
+                import PIL.JpegPresets
+                sys.modules['JpegPresets'] = PIL.JpegPresets
+            except ImportError:
+                pass
+
         for plugin in plugins:
             try:
                 if have_PIL:
 
         if Image.OPEN or Image.SAVE:
             Image._initialized = 2
+            return 1
+
     Image.init = init