namespaced operation works when installed as a zipped egg using 'sudo python[3] setup.py easy_install -l --zip-ok .'

This commit is contained in:
wiredfool 2013-04-15 10:57:37 -07:00
parent b0fffd24a4
commit 026f6bb61e
3 changed files with 56 additions and 30 deletions

View File

@ -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

View File

@ -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']

View File

@ -499,4 +499,5 @@ setup(
scripts=glob.glob("Scripts/pil*.py"),
keywords=["Imaging",],
license='Standard PIL License',
zip_safe=True,
)