4
# $Id: //modules/pil/setup.py#7 $
6
# Usage: python setup.py install
8
# before running this script, build the libImaging directory
9
# and all support libraries (the JPEG library, ZLIB, etc).
12
from distutils.core import setup, Extension
16
# --------------------------------------------------------------------
20
DESCRIPTION = "Python Imaging Library"
21
AUTHOR = "Secret Labs AB / PythonWare", "info@pythonware.com"
22
HOMEPAGE = "http://www.pythonware.com/products/pil"
24
# on windows, the build script expects to find both library files and
25
# include files in the directories below. tweak as necessary.
26
JPEGDIR = "../../kits/jpeg-6b"
27
ZLIBDIR = "../../kits/zlib-1.1.3"
29
# on windows, the following is used to control how and where to search
30
# for Tcl/Tk files. None enables automatic searching; to override, set
31
# this to a directory name
34
from PIL.Image import VERSION
36
PY_VERSION = sys.version[0] + sys.version[2]
38
# --------------------------------------------------------------------
39
# configure imaging module
43
INCLUDE_DIRS = ["libImaging"]
44
LIBRARY_DIRS = ["libImaging"]
45
LIBRARIES = ["Imaging"]
51
# parse ImConfig.h to figure out what external libraries we're using
52
for line in open(os.path.join("libImaging", "ImConfig.h")).readlines():
53
m = re.match("#define\s+HAVE_LIB([A-Z]+)", line)
58
if sys.platform == "win32":
59
LIBRARIES.append("jpeg")
60
INCLUDE_DIRS.append(JPEGDIR)
61
LIBRARY_DIRS.append(JPEGDIR)
63
LIBRARIES.append("jpeg")
66
LIBRARIES.append("tiff")
69
if sys.platform == "win32":
70
LIBRARIES.append("zlib")
71
INCLUDE_DIRS.append(ZLIBDIR)
72
LIBRARY_DIRS.append(ZLIBDIR)
76
if sys.platform == "win32":
77
# standard windows libraries
78
LIBRARIES.extend(["kernel32", "user32", "gdi32"])
83
["_imaging.c", "decode.c", "encode.c", "map.c", "display.c",
84
"outline.c", "path.c"],
85
include_dirs=INCLUDE_DIRS,
86
library_dirs=LIBRARY_DIRS,
94
# look for old, unsafe version of zlib
95
# note: this only finds zlib.h if ZLIBDIR is properly set
96
zlibfile = os.path.join(ZLIBDIR, "zlib.h")
97
if os.path.isfile(zlibfile):
98
for line in open(zlibfile).readlines():
99
m = re.match('#define\s+ZLIB_VERSION\s+"([^"]*)"', line)
101
if m.group(1) < "1.1.4":
103
print "*** Warning: zlib", m.group(1),
104
print "may contain a security vulnerability."
105
print "*** Consider upgrading to zlib 1.1.4 or newer."
107
print "http://www.gzip.org/zlib/advisory-2002-03-11.txt"
111
# --------------------------------------------------------------------
112
# configure imagingtk module
116
TCL_VERSION = _tkinter.TCL_VERSION[:3]
117
except (ImportError, AttributeError):
120
INCLUDE_DIRS = ["libImaging"]
121
LIBRARY_DIRS = ["libImaging"]
122
LIBRARIES = ["Imaging"]
123
if sys.platform == "win32":
124
# locate tcl/tk on windows
129
os.path.join("/py" + PY_VERSION, "Tcl"),
130
os.path.join(os.environ.get("ProgramFiles", ""), "Tcl"),
131
# FIXME: add more directories here?
134
TCLROOT = os.path.abspath(root)
135
if os.path.isfile(os.path.join(TCLROOT, "include", "tk.h")):
138
print "*** cannot find Tcl/Tk headers and library files"
139
print " change the TCLROOT variable in the setup.py file"
142
# print "using Tcl/Tk libraries at", TCLROOT
143
# print "using Tcl/Tk version", TCL_VERSION
145
version = TCL_VERSION[0] + TCL_VERSION[2]
146
INCLUDE_DIRS.append(os.path.join(TCLROOT, "include"))
147
LIBRARY_DIRS.append(os.path.join(TCLROOT, "lib"))
148
LIBRARIES.extend(["tk" + version, "tcl" + version])
150
# assume the libraries are installed in the default location
151
LIBRARIES.extend(["tk" + TCL_VERSION, "tcl" + TCL_VERSION])
156
["_imagingtk.c", "Tk/tkImaging.c"],
157
include_dirs=INCLUDE_DIRS,
158
library_dirs=LIBRARY_DIRS,
169
author_email=AUTHOR[1],
170
description=DESCRIPTION,
174
package_dir={"": "PIL"},
175
ext_modules = MODULES,