From 026f6bb61eca4a2fdf3c92097ee3394953214be3 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Mon, 15 Apr 2013 10:57:37 -0700 Subject: [PATCH] namespaced operation works when installed as a zipped egg using 'sudo python[3] setup.py easy_install -l --zip-ok .' --- PIL/Image.py | 40 ++++++++++------------------------------ PIL/__init__.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ setup.py | 1 + 3 files changed, 56 insertions(+), 30 deletions(-) diff --git a/PIL/Image.py b/PIL/Image.py index a24750648..51694ab86 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -26,8 +26,7 @@ from __future__ import print_function -VERSION = "1.1.7" -PILLOW_VERSION = "2.0.0" +from PIL import VERSION, PILLOW_VERSION, _plugins try: import warnings @@ -336,34 +335,15 @@ def init(): if _initialized >= 2: return 0 - visited = {} - - directories = sys.path - - try: - directories = directories + [os.path.dirname(__file__)] - except NameError: - pass - - # only check directories (including current, if present in the path) - for directory in filter(isDirectory, directories): - fullpath = os.path.abspath(directory) - if fullpath in visited: - continue - for file in os.listdir(directory): - if file[-14:] == "ImagePlugin.py": - f, e = os.path.splitext(file) - try: - sys.path.insert(0, directory) - try: - __import__(f, globals(), locals(), []) - finally: - del sys.path[0] - except ImportError: - if DEBUG: - print("Image: failed to import", end=' ') - print(f, ":", sys.exc_info()[1]) - visited[fullpath] = None + for plugin in _plugins: + try: + if DEBUG: + print ("Importing %s"%plugin) + __import__("PIL.%s"%plugin, globals(), locals(), []) + except ImportError: + if DEBUG: + print("Image: failed to import", end=' ') + print(plugin, ":", sys.exc_info()[1]) if OPEN or SAVE: _initialized = 2 diff --git a/PIL/__init__.py b/PIL/__init__.py index ed54d26f6..a50fae3ce 100644 --- a/PIL/__init__.py +++ b/PIL/__init__.py @@ -10,3 +10,48 @@ # # ;-) + +VERSION = '1.1.7' # PIL version +PILLOW_VERSION = '2.0.0' # Pillow + +_plugins = ['ArgImagePlugin', + 'BmpImagePlugin', + 'BufrStubImagePlugin', + 'CurImagePlugin', + 'DcxImagePlugin', + 'EpsImagePlugin', + 'FitsStubImagePlugin', + 'FliImagePlugin', + 'FpxImagePlugin', + 'GbrImagePlugin', + 'GifImagePlugin', + 'GribStubImagePlugin', + 'Hdf5StubImagePlugin', + 'IcnsImagePlugin', + 'IcoImagePlugin', + 'ImImagePlugin', + 'ImtImagePlugin', + 'IptcImagePlugin', + 'JpegImagePlugin', + 'McIdasImagePlugin', + 'MicImagePlugin', + 'MpegImagePlugin', + 'MspImagePlugin', + 'PalmImagePlugin', + 'PcdImagePlugin', + 'PcxImagePlugin', + 'PdfImagePlugin', + 'PixarImagePlugin', + 'PngImagePlugin', + 'PpmImagePlugin', + 'PsdImagePlugin', + 'SgiImagePlugin', + 'SpiderImagePlugin', + 'SunImagePlugin', + 'TgaImagePlugin', + 'TiffImagePlugin', + 'WebPImagePlugin', + 'WmfImagePlugin', + 'XbmImagePlugin', + 'XpmImagePlugin', + 'XVThumbImagePlugin'] diff --git a/setup.py b/setup.py index 429cec61d..847d4b9ce 100644 --- a/setup.py +++ b/setup.py @@ -499,4 +499,5 @@ setup( scripts=glob.glob("Scripts/pil*.py"), keywords=["Imaging",], license='Standard PIL License', + zip_safe=True, )