2012-10-11 16:57:21 +04:00
|
|
|
from __future__ import print_function
|
2010-11-28 23:55:38 +03:00
|
|
|
import glob
|
2010-11-28 23:15:53 +03:00
|
|
|
import os
|
2010-11-28 23:20:53 +03:00
|
|
|
import platform
|
2010-11-28 23:15:53 +03:00
|
|
|
import re
|
|
|
|
import struct
|
|
|
|
import sys
|
2010-11-28 21:35:36 +03:00
|
|
|
|
2010-11-28 23:15:53 +03:00
|
|
|
from distutils.command.build_ext import build_ext
|
|
|
|
from distutils import sysconfig
|
2010-11-28 23:55:38 +03:00
|
|
|
from setuptools import Extension, setup, find_packages
|
2010-11-28 21:35:36 +03:00
|
|
|
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
_IMAGING = (
|
|
|
|
"decode", "encode", "map", "display", "outline", "path",
|
|
|
|
)
|
|
|
|
|
|
|
|
_LIB_IMAGING = (
|
2012-12-04 19:44:26 +04:00
|
|
|
"Access", "AlphaComposite", "Antialias", "Bands", "BitDecode", "Blend",
|
|
|
|
"Chops", "Convert", "ConvertYCbCr", "Copy", "Crc32", "Crop", "Dib", "Draw",
|
2010-11-28 23:15:53 +03:00
|
|
|
"Effects", "EpsEncode", "File", "Fill", "Filter", "FliDecode",
|
|
|
|
"Geometry", "GetBBox", "GifDecode", "GifEncode", "HexDecode",
|
|
|
|
"Histo", "JpegDecode", "JpegEncode", "LzwDecode", "Matrix",
|
|
|
|
"ModeFilter", "MspDecode", "Negative", "Offset", "Pack",
|
2013-03-11 23:33:04 +04:00
|
|
|
"PackDecode", "Palette", "Paste", "Quant", "QuantOctree", "QuantHash",
|
2010-11-28 23:15:53 +03:00
|
|
|
"QuantHeap", "PcdDecode", "PcxDecode", "PcxEncode", "Point",
|
|
|
|
"RankFilter", "RawDecode", "RawEncode", "Storage", "SunRleDecode",
|
|
|
|
"TgaRleDecode", "Unpack", "UnpackYCC", "UnsharpMask", "XbmDecode",
|
2013-03-09 07:51:59 +04:00
|
|
|
"XbmEncode", "ZipDecode", "ZipEncode", "TiffDecode")
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
|
|
|
|
def _add_directory(path, dir, where=None):
|
|
|
|
if dir and os.path.isdir(dir) and dir not in path:
|
|
|
|
if where is None:
|
|
|
|
path.append(dir)
|
|
|
|
else:
|
|
|
|
path.insert(where, dir)
|
|
|
|
|
|
|
|
|
|
|
|
def _find_include_file(self, include):
|
|
|
|
for directory in self.compiler.include_dirs:
|
|
|
|
if os.path.isfile(os.path.join(directory, include)):
|
|
|
|
return 1
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
def _find_library_file(self, library):
|
2013-04-24 08:09:32 +04:00
|
|
|
# Fix for 3.2.x <3.2.4, 3.3.0, shared lib extension is the python shared lib
|
|
|
|
# extension, not the system shared lib extension: e.g. .cpython-33.so vs .so
|
|
|
|
# See Python bug http://bugs.python.org/16754
|
|
|
|
if 'cpython' in self.compiler.shared_lib_extension:
|
|
|
|
existing = self.compiler.shared_lib_extension
|
|
|
|
self.compiler.shared_lib_extension = "." + existing.split('.')[-1]
|
|
|
|
ret = self.compiler.find_library_file(self.compiler.library_dirs, library)
|
|
|
|
self.compiler.shared_lib_extension = existing
|
|
|
|
return ret
|
|
|
|
else:
|
|
|
|
return self.compiler.find_library_file(self.compiler.library_dirs, library)
|
|
|
|
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
def _find_version(filename):
|
|
|
|
for line in open(filename).readlines():
|
|
|
|
m = re.search("VERSION\s*=\s*\"([^\"]+)\"", line)
|
|
|
|
if m:
|
|
|
|
return m.group(1)
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
2010-11-28 23:20:53 +03:00
|
|
|
def _lib_include(root):
|
|
|
|
# map root to (root/lib, root/include)
|
|
|
|
return os.path.join(root, "lib"), os.path.join(root, "include")
|
|
|
|
|
|
|
|
|
2010-11-28 23:15:53 +03:00
|
|
|
def _read(file):
|
2010-11-28 21:40:10 +03:00
|
|
|
return open(file, 'rb').read()
|
2010-11-28 21:35:36 +03:00
|
|
|
|
2010-11-28 23:15:53 +03:00
|
|
|
try:
|
|
|
|
import _tkinter
|
|
|
|
except ImportError:
|
|
|
|
_tkinter = None
|
|
|
|
|
|
|
|
|
2010-11-28 23:31:09 +03:00
|
|
|
NAME = 'Pillow'
|
2013-03-06 15:14:32 +04:00
|
|
|
VERSION = '2.0.0'
|
2010-11-28 23:26:48 +03:00
|
|
|
PIL_VERSION = '1.1.7'
|
2010-11-28 23:15:53 +03:00
|
|
|
TCL_ROOT = None
|
|
|
|
JPEG_ROOT = None
|
|
|
|
ZLIB_ROOT = None
|
2013-03-15 08:31:16 +04:00
|
|
|
TIFF_ROOT = None
|
2010-11-28 23:15:53 +03:00
|
|
|
FREETYPE_ROOT = None
|
|
|
|
LCMS_ROOT = None
|
|
|
|
|
|
|
|
|
|
|
|
class pil_build_ext(build_ext):
|
|
|
|
|
|
|
|
def build_extensions(self):
|
|
|
|
|
|
|
|
global TCL_ROOT
|
|
|
|
|
|
|
|
library_dirs = []
|
|
|
|
include_dirs = []
|
|
|
|
|
|
|
|
_add_directory(include_dirs, "libImaging")
|
|
|
|
|
2013-01-09 15:48:06 +04:00
|
|
|
#
|
|
|
|
# add configured kits
|
|
|
|
|
2013-01-29 18:25:55 +04:00
|
|
|
for root in (TCL_ROOT, JPEG_ROOT, TIFF_ROOT, ZLIB_ROOT,
|
2013-01-09 15:48:06 +04:00
|
|
|
FREETYPE_ROOT, LCMS_ROOT):
|
|
|
|
if isinstance(root, type(())):
|
|
|
|
lib_root, include_root = root
|
|
|
|
else:
|
|
|
|
lib_root = include_root = root
|
|
|
|
_add_directory(library_dirs, lib_root)
|
|
|
|
_add_directory(include_dirs, include_root)
|
|
|
|
|
2010-11-28 23:15:53 +03:00
|
|
|
#
|
|
|
|
# add platform directories
|
|
|
|
|
|
|
|
if sys.platform == "cygwin":
|
|
|
|
# pythonX.Y.dll.a is in the /usr/lib/pythonX.Y/config directory
|
|
|
|
_add_directory(library_dirs, os.path.join(
|
2011-09-07 21:40:53 +04:00
|
|
|
"/usr/lib", "python%s" % sys.version[:3], "config"))
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
elif sys.platform == "darwin":
|
|
|
|
# attempt to make sure we pick freetype2 over other versions
|
|
|
|
_add_directory(include_dirs, "/sw/include/freetype2")
|
|
|
|
_add_directory(include_dirs, "/sw/lib/freetype2/include")
|
|
|
|
# fink installation directories
|
|
|
|
_add_directory(library_dirs, "/sw/lib")
|
|
|
|
_add_directory(include_dirs, "/sw/include")
|
|
|
|
# darwin ports installation directories
|
|
|
|
_add_directory(library_dirs, "/opt/local/lib")
|
|
|
|
_add_directory(include_dirs, "/opt/local/include")
|
|
|
|
# freetype2 ships with X11
|
2011-10-22 09:35:35 +04:00
|
|
|
_add_directory(library_dirs, "/usr/X11/lib")
|
|
|
|
_add_directory(include_dirs, "/usr/X11/include")
|
2010-11-28 23:15:53 +03:00
|
|
|
|
2011-09-07 18:08:35 +04:00
|
|
|
elif sys.platform.startswith("linux"):
|
2013-03-15 08:31:16 +04:00
|
|
|
for platform_ in (platform.processor(),platform.architecture()[0]):
|
|
|
|
if not platform_: continue
|
|
|
|
|
|
|
|
if platform_ in ["x86_64", "64bit"]:
|
|
|
|
_add_directory(library_dirs, "/lib64")
|
|
|
|
_add_directory(library_dirs, "/usr/lib64")
|
|
|
|
_add_directory(library_dirs, "/usr/lib/x86_64-linux-gnu")
|
|
|
|
break
|
|
|
|
elif platform_ in ["i386", "i686", "32bit"]:
|
|
|
|
_add_directory(library_dirs, "/usr/lib/i386-linux-gnu")
|
|
|
|
break
|
2013-02-18 20:16:13 +04:00
|
|
|
else:
|
|
|
|
raise ValueError("Unable to identify Linux platform: `%s`" % platform_)
|
2011-05-31 19:24:38 +04:00
|
|
|
|
2011-09-07 21:40:53 +04:00
|
|
|
# XXX Kludge. Above /\ we brute force support multiarch. Here we
|
2011-05-31 19:24:38 +04:00
|
|
|
# try Barry's more general approach. Afterward, something should
|
|
|
|
# work ;-)
|
|
|
|
self.add_multiarch_paths()
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
_add_directory(library_dirs, "/usr/local/lib")
|
|
|
|
# FIXME: check /opt/stuff directories here?
|
|
|
|
|
|
|
|
prefix = sysconfig.get_config_var("prefix")
|
|
|
|
if prefix:
|
|
|
|
_add_directory(library_dirs, os.path.join(prefix, "lib"))
|
|
|
|
_add_directory(include_dirs, os.path.join(prefix, "include"))
|
|
|
|
|
|
|
|
#
|
|
|
|
# locate tkinter libraries
|
|
|
|
|
2013-03-15 08:31:16 +04:00
|
|
|
|
2010-11-28 23:15:53 +03:00
|
|
|
if _tkinter:
|
|
|
|
TCL_VERSION = _tkinter.TCL_VERSION[:3]
|
|
|
|
|
|
|
|
if _tkinter and not TCL_ROOT:
|
|
|
|
# we have Tkinter but the TCL_ROOT variable was not set;
|
|
|
|
# try to locate appropriate Tcl/Tk libraries
|
|
|
|
PYVERSION = sys.version[0] + sys.version[2]
|
|
|
|
TCLVERSION = TCL_VERSION[0] + TCL_VERSION[2]
|
|
|
|
roots = [
|
|
|
|
# common installation directories, mostly for Windows
|
|
|
|
# (for Unix-style platforms, we'll check in well-known
|
|
|
|
# locations later)
|
|
|
|
os.path.join("/py" + PYVERSION, "Tcl"),
|
|
|
|
os.path.join("/python" + PYVERSION, "Tcl"),
|
|
|
|
"/Tcl", "/Tcl" + TCLVERSION, "/Tcl" + TCL_VERSION,
|
|
|
|
os.path.join(os.environ.get("ProgramFiles", ""), "Tcl"),
|
|
|
|
]
|
|
|
|
for TCL_ROOT in roots:
|
|
|
|
TCL_ROOT = os.path.abspath(TCL_ROOT)
|
|
|
|
if os.path.isfile(os.path.join(TCL_ROOT, "include", "tk.h")):
|
|
|
|
# FIXME: use distutils logging (?)
|
2012-06-12 09:13:40 +04:00
|
|
|
print("--- using Tcl/Tk libraries at", TCL_ROOT)
|
|
|
|
print("--- using Tcl/Tk version", TCL_VERSION)
|
2010-11-28 23:20:53 +03:00
|
|
|
TCL_ROOT = _lib_include(TCL_ROOT)
|
2010-11-28 23:15:53 +03:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
TCL_ROOT = None
|
2013-03-15 08:31:16 +04:00
|
|
|
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
#
|
|
|
|
# add standard directories
|
|
|
|
|
|
|
|
# look for tcl specific subdirectory (e.g debian)
|
|
|
|
if _tkinter:
|
|
|
|
tcl_dir = "/usr/include/tcl" + TCL_VERSION
|
|
|
|
if os.path.isfile(os.path.join(tcl_dir, "tk.h")):
|
|
|
|
_add_directory(include_dirs, tcl_dir)
|
|
|
|
|
|
|
|
# standard locations
|
|
|
|
_add_directory(library_dirs, "/usr/local/lib")
|
|
|
|
_add_directory(include_dirs, "/usr/local/include")
|
|
|
|
|
|
|
|
_add_directory(library_dirs, "/usr/lib")
|
|
|
|
_add_directory(include_dirs, "/usr/include")
|
|
|
|
|
|
|
|
#
|
|
|
|
# insert new dirs *before* default libs, to avoid conflicts
|
|
|
|
# between Python PYD stub libs and real libraries
|
|
|
|
|
|
|
|
self.compiler.library_dirs = library_dirs + self.compiler.library_dirs
|
|
|
|
self.compiler.include_dirs = include_dirs + self.compiler.include_dirs
|
|
|
|
|
|
|
|
#
|
|
|
|
# look for available libraries
|
|
|
|
|
|
|
|
class feature:
|
2013-03-12 18:30:59 +04:00
|
|
|
zlib = jpeg = tiff = freetype = tcl = tk = lcms = webp = None
|
2010-11-28 23:15:53 +03:00
|
|
|
feature = feature()
|
|
|
|
|
|
|
|
if _find_include_file(self, "zlib.h"):
|
|
|
|
if _find_library_file(self, "z"):
|
|
|
|
feature.zlib = "z"
|
|
|
|
elif sys.platform == "win32" and _find_library_file(self, "zlib"):
|
|
|
|
feature.zlib = "zlib" # alternative name
|
|
|
|
|
|
|
|
if _find_include_file(self, "jpeglib.h"):
|
|
|
|
if _find_library_file(self, "jpeg"):
|
|
|
|
feature.jpeg = "jpeg"
|
|
|
|
elif sys.platform == "win32" and _find_library_file(self,
|
|
|
|
"libjpeg"):
|
|
|
|
feature.jpeg = "libjpeg" # alternative name
|
|
|
|
|
|
|
|
if _find_library_file(self, "tiff"):
|
|
|
|
feature.tiff = "tiff"
|
2013-03-14 00:40:12 +04:00
|
|
|
if sys.platform == "win32" and _find_library_file(self, "libtiff"):
|
2013-03-09 07:51:59 +04:00
|
|
|
feature.tiff = "libtiff"
|
2013-03-14 00:40:12 +04:00
|
|
|
if sys.platform == "darwin" and _find_library_file(self, "libtiff"):
|
2013-03-09 07:51:59 +04:00
|
|
|
feature.tiff = "libtiff"
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
if _find_library_file(self, "freetype"):
|
|
|
|
# look for freetype2 include files
|
|
|
|
freetype_version = 0
|
|
|
|
for dir in self.compiler.include_dirs:
|
|
|
|
if os.path.isfile(os.path.join(dir, "ft2build.h")):
|
|
|
|
freetype_version = 21
|
|
|
|
dir = os.path.join(dir, "freetype2")
|
|
|
|
break
|
|
|
|
dir = os.path.join(dir, "freetype2")
|
|
|
|
if os.path.isfile(os.path.join(dir, "ft2build.h")):
|
|
|
|
freetype_version = 21
|
|
|
|
break
|
|
|
|
if os.path.isdir(os.path.join(dir, "freetype")):
|
|
|
|
freetype_version = 20
|
|
|
|
break
|
|
|
|
if freetype_version:
|
|
|
|
feature.freetype = "freetype"
|
|
|
|
feature.freetype_version = freetype_version
|
|
|
|
if dir:
|
|
|
|
_add_directory(self.compiler.include_dirs, dir, 0)
|
|
|
|
|
|
|
|
if _find_include_file(self, "lcms.h"):
|
|
|
|
if _find_library_file(self, "lcms"):
|
|
|
|
feature.lcms = "lcms"
|
|
|
|
|
|
|
|
if _tkinter and _find_include_file(self, "tk.h"):
|
|
|
|
# the library names may vary somewhat (e.g. tcl84 or tcl8.4)
|
|
|
|
version = TCL_VERSION[0] + TCL_VERSION[2]
|
|
|
|
if _find_library_file(self, "tcl" + version):
|
|
|
|
feature.tcl = "tcl" + version
|
|
|
|
elif _find_library_file(self, "tcl" + TCL_VERSION):
|
|
|
|
feature.tcl = "tcl" + TCL_VERSION
|
|
|
|
if _find_library_file(self, "tk" + version):
|
|
|
|
feature.tk = "tk" + version
|
|
|
|
elif _find_library_file(self, "tk" + TCL_VERSION):
|
|
|
|
feature.tk = "tk" + TCL_VERSION
|
|
|
|
|
2013-03-12 18:30:59 +04:00
|
|
|
if _find_include_file(self, "webp/encode.h") and _find_include_file(self, "webp/decode.h"):
|
|
|
|
if _find_library_file(self, "webp"):
|
|
|
|
feature.webp = "webp"
|
|
|
|
|
2010-11-28 23:15:53 +03:00
|
|
|
#
|
|
|
|
# core library
|
|
|
|
|
|
|
|
files = ["_imaging.c"]
|
|
|
|
for file in _IMAGING:
|
|
|
|
files.append(file + ".c")
|
|
|
|
for file in _LIB_IMAGING:
|
|
|
|
files.append(os.path.join("libImaging", file + ".c"))
|
|
|
|
|
|
|
|
libs = []
|
|
|
|
defs = []
|
|
|
|
if feature.jpeg:
|
|
|
|
libs.append(feature.jpeg)
|
|
|
|
defs.append(("HAVE_LIBJPEG", None))
|
|
|
|
if feature.zlib:
|
|
|
|
libs.append(feature.zlib)
|
|
|
|
defs.append(("HAVE_LIBZ", None))
|
2013-03-09 07:51:59 +04:00
|
|
|
if feature.tiff:
|
|
|
|
libs.append(feature.tiff)
|
|
|
|
defs.append(("HAVE_LIBTIFF", None))
|
2010-11-28 23:15:53 +03:00
|
|
|
if sys.platform == "win32":
|
|
|
|
libs.extend(["kernel32", "user32", "gdi32"])
|
2012-06-12 09:13:40 +04:00
|
|
|
if struct.unpack("h", "\0\1".encode('ascii'))[0] == 1:
|
2010-11-28 23:15:53 +03:00
|
|
|
defs.append(("WORDS_BIGENDIAN", None))
|
|
|
|
|
|
|
|
exts = [(Extension(
|
2013-03-09 03:36:42 +04:00
|
|
|
"_imaging", files, libraries=libs, define_macros=defs))]
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
#
|
|
|
|
# additional libraries
|
|
|
|
|
|
|
|
if feature.freetype:
|
|
|
|
defs = []
|
|
|
|
if feature.freetype_version == 20:
|
|
|
|
defs.append(("USE_FREETYPE_2_0", None))
|
|
|
|
exts.append(Extension(
|
2013-03-09 03:36:42 +04:00
|
|
|
"_imagingft", ["_imagingft.c"], libraries=["freetype"],
|
2011-09-07 21:40:53 +04:00
|
|
|
define_macros=defs))
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
if os.path.isfile("_imagingtiff.c") and feature.tiff:
|
|
|
|
exts.append(Extension(
|
2013-03-09 03:36:42 +04:00
|
|
|
"_imagingtiff", ["_imagingtiff.c"], libraries=["tiff"]))
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
if os.path.isfile("_imagingcms.c") and feature.lcms:
|
|
|
|
extra = []
|
|
|
|
if sys.platform == "win32":
|
|
|
|
extra.extend(["user32", "gdi32"])
|
|
|
|
exts.append(Extension(
|
2013-03-09 03:36:42 +04:00
|
|
|
"_imagingcms", ["_imagingcms.c"], libraries=["lcms"] + extra))
|
2010-11-28 23:15:53 +03:00
|
|
|
|
2013-03-12 18:30:59 +04:00
|
|
|
if os.path.isfile("_webp.c") and feature.webp:
|
|
|
|
exts.append(Extension(
|
|
|
|
"_webp", ["_webp.c"], libraries=["webp"]))
|
|
|
|
|
|
|
|
|
2010-11-28 23:15:53 +03:00
|
|
|
if sys.platform == "darwin":
|
|
|
|
# locate Tcl/Tk frameworks
|
|
|
|
frameworks = []
|
|
|
|
framework_roots = [
|
|
|
|
"/Library/Frameworks",
|
2011-09-07 21:40:53 +04:00
|
|
|
"/System/Library/Frameworks"]
|
2010-11-28 23:15:53 +03:00
|
|
|
for root in framework_roots:
|
|
|
|
if (os.path.exists(os.path.join(root, "Tcl.framework")) and
|
|
|
|
os.path.exists(os.path.join(root, "Tk.framework"))):
|
2012-11-02 01:08:29 +04:00
|
|
|
print("--- using frameworks at %s" % root)
|
2010-11-28 23:15:53 +03:00
|
|
|
frameworks = ["-framework", "Tcl", "-framework", "Tk"]
|
|
|
|
dir = os.path.join(root, "Tcl.framework", "Headers")
|
|
|
|
_add_directory(self.compiler.include_dirs, dir, 0)
|
|
|
|
dir = os.path.join(root, "Tk.framework", "Headers")
|
|
|
|
_add_directory(self.compiler.include_dirs, dir, 1)
|
|
|
|
break
|
|
|
|
if frameworks:
|
|
|
|
exts.append(Extension(
|
2013-03-09 03:36:42 +04:00
|
|
|
"_imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"],
|
2011-09-07 21:40:53 +04:00
|
|
|
extra_compile_args=frameworks, extra_link_args=frameworks))
|
2010-11-28 23:15:53 +03:00
|
|
|
feature.tcl = feature.tk = 1 # mark as present
|
|
|
|
elif feature.tcl and feature.tk:
|
|
|
|
exts.append(Extension(
|
2013-03-09 03:36:42 +04:00
|
|
|
"_imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"],
|
2011-09-07 21:40:53 +04:00
|
|
|
libraries=[feature.tcl, feature.tk]))
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
if os.path.isfile("_imagingmath.c"):
|
2013-03-09 03:36:42 +04:00
|
|
|
exts.append(Extension("_imagingmath", ["_imagingmath.c"]))
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
self.extensions[:] = exts
|
|
|
|
|
|
|
|
build_ext.build_extensions(self)
|
|
|
|
|
|
|
|
#
|
|
|
|
# sanity and security checks
|
|
|
|
|
|
|
|
unsafe_zlib = None
|
|
|
|
|
|
|
|
if feature.zlib:
|
|
|
|
unsafe_zlib = self.check_zlib_version(self.compiler.include_dirs)
|
|
|
|
|
|
|
|
self.summary_report(feature, unsafe_zlib)
|
|
|
|
|
|
|
|
def summary_report(self, feature, unsafe_zlib):
|
2011-09-07 22:28:38 +04:00
|
|
|
|
2012-06-12 09:13:40 +04:00
|
|
|
print("-" * 68)
|
2013-05-09 00:06:16 +04:00
|
|
|
print("SETUP SUMMARY (Pillow %s PIL fork, originally based on PIL %s)" % (VERSION, PIL_VERSION))
|
2012-06-12 09:13:40 +04:00
|
|
|
print("-" * 68)
|
2013-03-14 06:20:25 +04:00
|
|
|
print("version %s (Pillow)" % VERSION)
|
2012-06-12 09:13:40 +04:00
|
|
|
v = sys.version.split("[")
|
2012-11-02 01:08:29 +04:00
|
|
|
print("platform %s %s" % (sys.platform, v[0].strip()))
|
2010-11-28 23:15:53 +03:00
|
|
|
for v in v[1:]:
|
2012-11-02 01:08:29 +04:00
|
|
|
print(" [%s" % v.strip())
|
2012-06-12 09:13:40 +04:00
|
|
|
print("-" * 68)
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
options = [
|
|
|
|
(feature.tcl and feature.tk, "TKINTER"),
|
|
|
|
(feature.jpeg, "JPEG"),
|
|
|
|
(feature.zlib, "ZLIB (PNG/ZIP)"),
|
2013-03-15 16:47:10 +04:00
|
|
|
(feature.tiff, "TIFF G3/G4 (experimental)"),
|
2010-11-28 23:15:53 +03:00
|
|
|
(feature.freetype, "FREETYPE2"),
|
|
|
|
(feature.lcms, "LITTLECMS"),
|
2013-03-12 18:30:59 +04:00
|
|
|
(feature.webp, "WEBP"),
|
2010-11-28 23:15:53 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
all = 1
|
|
|
|
for option in options:
|
|
|
|
if option[0]:
|
2012-11-02 01:08:29 +04:00
|
|
|
print("--- %s support available" % option[1])
|
2010-11-28 23:15:53 +03:00
|
|
|
else:
|
2012-11-02 01:08:29 +04:00
|
|
|
print("*** %s support not available" % option[1])
|
2010-11-28 23:15:53 +03:00
|
|
|
if option[1] == "TKINTER" and _tkinter:
|
|
|
|
version = _tkinter.TCL_VERSION
|
2012-06-12 09:13:40 +04:00
|
|
|
print("(Tcl/Tk %s libraries needed)" % version)
|
2010-11-28 23:15:53 +03:00
|
|
|
all = 0
|
|
|
|
|
|
|
|
if feature.zlib and unsafe_zlib:
|
2012-11-02 01:08:29 +04:00
|
|
|
print("")
|
2012-06-12 09:13:40 +04:00
|
|
|
print("*** Warning: zlib", unsafe_zlib)
|
|
|
|
print("may contain a security vulnerability.")
|
|
|
|
print("*** Consider upgrading to zlib 1.2.3 or newer.")
|
|
|
|
print("*** See: http://www.kb.cert.org/vuls/id/238678")
|
|
|
|
print(" http://www.kb.cert.org/vuls/id/680620")
|
|
|
|
print(" http://www.gzip.org/zlib/advisory-2002-03-11.txt")
|
2012-11-02 01:08:29 +04:00
|
|
|
print("")
|
2010-11-28 23:15:53 +03:00
|
|
|
|
2012-06-12 09:13:40 +04:00
|
|
|
print("-" * 68)
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
if not all:
|
2012-06-12 09:13:40 +04:00
|
|
|
print("To add a missing option, make sure you have the required")
|
|
|
|
print("library, and set the corresponding ROOT variable in the")
|
|
|
|
print("setup.py script.")
|
2013-03-14 15:07:46 +04:00
|
|
|
print("")
|
2010-11-28 23:15:53 +03:00
|
|
|
|
2012-06-12 09:13:40 +04:00
|
|
|
print("To check the build, run the selftest.py script.")
|
2013-03-14 15:07:46 +04:00
|
|
|
print("")
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
def check_zlib_version(self, include_dirs):
|
|
|
|
# look for unsafe versions of zlib
|
|
|
|
for dir in include_dirs:
|
|
|
|
zlibfile = os.path.join(dir, "zlib.h")
|
|
|
|
if os.path.isfile(zlibfile):
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
return
|
|
|
|
for line in open(zlibfile).readlines():
|
|
|
|
m = re.match('#define\s+ZLIB_VERSION\s+"([^"]*)"', line)
|
|
|
|
if not m:
|
|
|
|
continue
|
|
|
|
if m.group(1) < "1.2.3":
|
|
|
|
return m.group(1)
|
2010-11-28 21:35:36 +03:00
|
|
|
|
2011-05-31 19:24:38 +04:00
|
|
|
# http://hg.python.org/users/barry/rev/7e8deab93d5a
|
|
|
|
def add_multiarch_paths(self):
|
|
|
|
# Debian/Ubuntu multiarch support.
|
|
|
|
# https://wiki.ubuntu.com/MultiarchSpec
|
2011-09-07 21:40:53 +04:00
|
|
|
# self.build_temp
|
2011-05-31 19:24:38 +04:00
|
|
|
tmpfile = os.path.join(self.build_temp, 'multiarch')
|
|
|
|
if not os.path.exists(self.build_temp):
|
|
|
|
os.makedirs(self.build_temp)
|
|
|
|
ret = os.system(
|
|
|
|
'dpkg-architecture -qDEB_HOST_MULTIARCH > %s 2> /dev/null' %
|
|
|
|
tmpfile)
|
|
|
|
try:
|
|
|
|
if ret >> 8 == 0:
|
2012-10-11 16:57:21 +04:00
|
|
|
fp = open(tmpfile, 'r')
|
2011-06-02 21:03:05 +04:00
|
|
|
multiarch_path_component = fp.readline().strip()
|
2011-05-31 19:33:28 +04:00
|
|
|
_add_directory(self.compiler.library_dirs,
|
|
|
|
'/usr/lib/' + multiarch_path_component)
|
|
|
|
_add_directory(self.compiler.include_dirs,
|
|
|
|
'/usr/include/' + multiarch_path_component)
|
|
|
|
finally:
|
|
|
|
os.unlink(tmpfile)
|
2011-05-31 19:24:38 +04:00
|
|
|
|
2010-11-28 21:35:36 +03:00
|
|
|
setup(
|
|
|
|
name=NAME,
|
|
|
|
version=VERSION,
|
|
|
|
description='Python Imaging Library (fork)',
|
|
|
|
long_description=(
|
2013-03-08 18:12:06 +04:00
|
|
|
_read('README.rst') + b'\n' +
|
|
|
|
_read('docs/HISTORY.txt') + b'\n' +
|
2013-03-14 15:25:22 +04:00
|
|
|
_read('docs/CONTRIBUTORS.txt')).decode('utf-8'),
|
2010-11-28 21:35:36 +03:00
|
|
|
author='Alex Clark (fork author)',
|
|
|
|
author_email='aclark@aclark.net',
|
2013-03-15 21:42:19 +04:00
|
|
|
url='http://python-imaging.github.com/',
|
2010-11-28 21:44:03 +03:00
|
|
|
classifiers=[
|
|
|
|
"Development Status :: 6 - Mature",
|
|
|
|
"Topic :: Multimedia :: Graphics",
|
|
|
|
"Topic :: Multimedia :: Graphics :: Capture :: Digital Camera",
|
|
|
|
"Topic :: Multimedia :: Graphics :: Capture :: Scanners",
|
|
|
|
"Topic :: Multimedia :: Graphics :: Capture :: Screen Capture",
|
|
|
|
"Topic :: Multimedia :: Graphics :: Graphics Conversion",
|
|
|
|
"Topic :: Multimedia :: Graphics :: Viewers",
|
2012-10-29 22:50:20 +04:00
|
|
|
"Programming Language :: Python :: 2",
|
|
|
|
"Programming Language :: Python :: 2.6",
|
|
|
|
"Programming Language :: Python :: 2.7",
|
|
|
|
"Programming Language :: Python :: 3",
|
|
|
|
"Programming Language :: Python :: 3.2",
|
|
|
|
"Programming Language :: Python :: 3.3",
|
2010-11-28 21:44:03 +03:00
|
|
|
],
|
2010-11-28 23:15:53 +03:00
|
|
|
cmdclass={"build_ext": pil_build_ext},
|
2013-03-09 03:36:42 +04:00
|
|
|
ext_modules=[Extension("_imaging", ["_imaging.c"])],
|
2010-11-28 23:55:38 +03:00
|
|
|
packages=find_packages(),
|
2011-09-07 21:40:53 +04:00
|
|
|
scripts=glob.glob("Scripts/pil*.py"),
|
2013-03-09 04:47:20 +04:00
|
|
|
keywords=["Imaging",],
|
|
|
|
license='Standard PIL License',
|
2010-11-28 21:35:36 +03:00
|
|
|
)
|