Changeset 308

Show
Ignore:
Timestamp:
Mon Mar 12 18:39:58 2007
Author:
giovannibajo
Message:

Fix support for PIL when imported without top-level package.

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/hooks/hook-PIL.Image.py

    r281 r308  
    16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA  
    17 17  
    18   hiddenimports = []  
    19    
    20 18 # FIXME: for a strange bug in Python's import machinery, we need to adjust  
    21 19 # the module name before proceeding to the PIL import. The name would  
     
    26 24 __name__ = "hook-image"  
    27 25  
    28   def install_Image(lis):  
    29       import Image  
    30       # PIL uses lazy initialization.  
    31       # you candecide if you want only the  
    32       # default stuff:  
    33       Image.preinit()  
    34       # or just everything:  
    35       Image.init()  
    36       import sys  
    37       for name in sys.modules:  
    38           if name[-11:] == "ImagePlugin":  
    39               lis.append(name)  
    40    
    41   install_Image(hiddenimports)  
      26 # Forward to shared code for PIL. PIL can be imported either as a top-level package  
      27 # (from PIL import Image), or not (import Image), because it installs a  
      28 # PIL.pth.  
      29 from shared_PIL_Image import *  
  • trunk/hooks/hook-PIL.SpiderImagePlugin.py

    r281 r308  
    1   # Copyright (C) 2006, Giovanni Bajo  
      1 # Copyright (C) 2005, Giovanni Bajo  
    1 1 # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc.  
    2 2 #  
     
    16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA  
    17 17  
    18   # PIL's SpiderImagePlugin features a tkPhotoImage() method which imports  
    19   # ImageTk (and thus brings the whole Tcl/Tk library in).  
    20   # We cheat a little and remove the ImageTk import: I assume that if people  
    21   # are really using ImageTk in their application, they will also import it  
    22   # directly.  
    23   def hook(mod):  
    24       for i in range(len(mod.imports)):  
    25           if mod.imports[i][0] == "ImageTk":  
    26               del mod.imports[i]  
    27               break  
    28       return mod  
      18 # Forward to shared code for PIL. PIL can be imported either as a top-level package  
      19 # (from PIL import Image), or not (import Image), because it installs a  
      20 # PIL.pth.  
      21 from shared_PIL_SpiderImagePlugin import *  
  • trunk/hooks/hook-Image.py

    r43 r308  
    16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA  
    17 17  
    18   hiddenimports = []  
    19    
    20   def install_Image(lis):  
    21       import Image  
    22       # PIL uses lazy initialization.  
    23       # you candecide if you want only the  
    24       # default stuff:  
    25       Image.preinit()  
    26       # or just everything:  
    27       Image.init()  
    28       import sys  
    29       for name in sys.modules:  
    30           if name[-11:] == "ImagePlugin":  
    31               lis.append(name)  
    32    
    33   install_Image(hiddenimports)  
      18 # Forward to shared code for PIL. PIL can be imported either as a top-level package  
      19 # (from PIL import Image), or not (import Image), because it installs a  
      20 # PIL.pth.  
      21 from shared_PIL_Image import *  
  • trunk/doc/CHANGES.txt

    r306 r308  
    11 11  + Fix support for .py files with DOS line endings under Linux (fixes  
    12 12    PyOpenGL).  
      13  + Fix support for PIL when imported without top-level package ("import  
      14    Image").  
    13 15  
    14 16