~ubuntu-branches/ubuntu/precise/python-imaging/precise-updates

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-11-20 19:22:59 UTC
  • mfrom: (2.1.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091120192259-cmnfui5tv2jtq4xu
Tags: 1.1.7-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
2
#
3
3
# Setup script for PIL 1.1.5 and later
4
 
# $Id: setup.py 2582 2005-11-11 21:54:00Z fredrik $
5
4
#
6
5
# Usage: python setup.py install
7
6
#
34
33
#
35
34
# TIFF_ROOT = libinclude("/opt/tiff")
36
35
 
37
 
FREETYPE_ROOT = None
 
36
TCL_ROOT = None
38
37
JPEG_ROOT = None
 
38
ZLIB_ROOT = None
39
39
TIFF_ROOT = None
40
 
ZLIB_ROOT = None
41
 
TCL_ROOT = None
 
40
FREETYPE_ROOT = None
 
41
LCMS_ROOT = None
42
42
 
43
43
# FIXME: add mechanism to explicitly *disable* the use of a library
44
44
 
49
49
DESCRIPTION = "Python Imaging Library"
50
50
AUTHOR = "Secret Labs AB (PythonWare)", "info@pythonware.com"
51
51
HOMEPAGE = "http://www.pythonware.com/products/pil"
 
52
DOWNLOAD_URL = "http://effbot.org/downloads/%s-%s.tar.gz" # name, version
52
53
 
53
54
# --------------------------------------------------------------------
54
55
# Core library
67
68
    "PackDecode", "Palette", "Paste", "Quant", "QuantHash",
68
69
    "QuantHeap", "PcdDecode", "PcxDecode", "PcxEncode", "Point",
69
70
    "RankFilter", "RawDecode", "RawEncode", "Storage", "SunRleDecode",
70
 
    "TgaRleDecode", "Unpack", "UnpackYCC", "XbmDecode", "XbmEncode",
71
 
    "ZipDecode", "ZipEncode"
 
71
    "TgaRleDecode", "Unpack", "UnpackYCC", "UnsharpMask", "XbmDecode",
 
72
    "XbmEncode", "ZipDecode", "ZipEncode"
72
73
    ]
73
74
 
74
75
# --------------------------------------------------------------------
97
98
        else:
98
99
            path.insert(where, dir)
99
100
 
 
101
def find_include_file(self, include):
 
102
    for directory in self.compiler.include_dirs:
 
103
        if os.path.isfile(os.path.join(directory, include)):
 
104
            return 1
 
105
    return 0
 
106
 
100
107
def find_library_file(self, library):
101
108
    return self.compiler.find_library_file(self.compiler.library_dirs, library)
102
109
 
182
189
        #
183
190
        # add configured kits
184
191
 
185
 
        for root in [FREETYPE_ROOT, JPEG_ROOT, TCL_ROOT, TIFF_ROOT, ZLIB_ROOT]:
 
192
        for root in (TCL_ROOT, JPEG_ROOT, TCL_ROOT, TIFF_ROOT, ZLIB_ROOT,
 
193
                     FREETYPE_ROOT, LCMS_ROOT):
186
194
            if isinstance(root, type(())):
187
195
                lib_root, include_root = root
188
196
            else:
193
201
        #
194
202
        # add standard directories
195
203
 
196
 
        #
197
 
        # add Tcl include directory
198
 
 
199
 
        add_directory(include_dirs, "/usr/include/tcl8.5")
 
204
        # look for tcl specific subdirectory (e.g debian)
 
205
        if _tkinter:
 
206
            tcl_dir = "/usr/include/tcl" + TCL_VERSION
 
207
            if os.path.isfile(os.path.join(tcl_dir, "tk.h")):
 
208
                add_directory(include_dirs, tcl_dir)
 
209
 
 
210
        # standard locations
 
211
        add_directory(library_dirs, "/usr/local/lib")
 
212
        add_directory(include_dirs, "/usr/local/include")
 
213
 
 
214
        add_directory(library_dirs, "/usr/lib")
 
215
        add_directory(include_dirs, "/usr/include")
200
216
 
201
217
        #
202
218
        # insert new dirs *before* default libs, to avoid conflicts
209
225
        # look for available libraries
210
226
 
211
227
        class feature:
212
 
            zlib = jpeg = tiff = freetype = tcl = tk = None
 
228
            zlib = jpeg = tiff = freetype = tcl = tk = lcms = None
213
229
        feature = feature()
214
230
 
215
 
        if find_library_file(self, "z"):
216
 
            feature.zlib = "z"
217
 
        elif sys.platform == "win32" and find_library_file(self, "zlib"):
218
 
            feature.zlib = "zlib" # alternative name
 
231
        if find_include_file(self, "zlib.h"):
 
232
            if find_library_file(self, "z"):
 
233
                feature.zlib = "z"
 
234
            elif sys.platform == "win32" and find_library_file(self, "zlib"):
 
235
                feature.zlib = "zlib" # alternative name
219
236
 
220
 
        if find_library_file(self, "jpeg"):
221
 
            feature.jpeg = "jpeg"
222
 
        elif sys.platform == "win32" and find_library_file(self, "libjpeg"):
223
 
            feature.jpeg = "libjpeg" # alternative name
 
237
        if find_include_file(self, "jpeglib.h"):
 
238
            if find_library_file(self, "jpeg"):
 
239
                feature.jpeg = "jpeg"
 
240
            elif sys.platform == "win32" and find_library_file(self, "libjpeg"):
 
241
                feature.jpeg = "libjpeg" # alternative name
224
242
 
225
243
        if find_library_file(self, "tiff"):
226
244
            feature.tiff = "tiff"
246
264
                if dir:
247
265
                    add_directory(self.compiler.include_dirs, dir, 0)
248
266
 
249
 
        if _tkinter:
 
267
        if find_include_file(self, "lcms.h"):
 
268
            if find_library_file(self, "lcms"):
 
269
                feature.lcms = "lcms"
 
270
 
 
271
        if _tkinter and find_include_file(self, "tk.h"):
250
272
            # the library names may vary somewhat (e.g. tcl84 or tcl8.4)
251
273
            version = TCL_VERSION[0] + TCL_VERSION[2]
252
274
            if find_library_file(self, "tcl" + version):
301
323
                "_imagingtiff", ["_imagingtiff.c"], libraries=["tiff"]
302
324
                ))
303
325
 
 
326
        if os.path.isfile("_imagingcms.c") and feature.lcms:
 
327
            extra = []
 
328
            if sys.platform == "win32":
 
329
                extra.extend(["user32", "gdi32"])
 
330
            exts.append(Extension(
 
331
                "_imagingcms", ["_imagingcms.c"], libraries=["lcms"] + extra
 
332
                ))
 
333
 
304
334
        if sys.platform == "darwin":
305
335
            # locate Tcl/Tk frameworks
306
336
            frameworks = []
350
380
    def summary_report(self, feature, unsafe_zlib):
351
381
 
352
382
        print "-" * 68
353
 
        print "PIL", VERSION, "BUILD SUMMARY"
 
383
        print "PIL", VERSION, "SETUP SUMMARY"
354
384
        print "-" * 68
355
385
        print "version      ", VERSION
356
386
        v = string.split(sys.version, "[")
365
395
            (feature.zlib, "ZLIB (PNG/ZIP)"),
366
396
            # (feature.tiff, "experimental TIFF G3/G4 read"),
367
397
            (feature.freetype, "FREETYPE2"),
 
398
            (feature.lcms, "LITTLECMS"),
368
399
            ]
369
400
 
370
401
        all = 1
371
402
        for option in options:
372
403
            if option[0]:
373
 
                print "---", option[1], "support ok"
 
404
                print "---", option[1], "support available"
374
405
            else:
375
406
                print "***", option[1], "support not available",
376
407
                if option[1] == "TKINTER" and _tkinter:
441
472
            ],
442
473
        cmdclass = {"build_ext": pil_build_ext},
443
474
        description=DESCRIPTION,
444
 
        download_url="http://effbot.org/zone/pil-changes-116.htm",
 
475
        download_url=DOWNLOAD_URL % (NAME, VERSION),
445
476
        ext_modules = [Extension("_imaging", ["_imaging.c"])], # dummy
446
477
        extra_path = "PIL",
447
478
        license="Python (MIT style)",