2013-09-28 17:28:16 +04:00
|
|
|
# > pyroma .
|
|
|
|
# ------------------------------
|
|
|
|
# Checking .
|
|
|
|
# Found Pillow
|
|
|
|
# ------------------------------
|
|
|
|
# Final rating: 10/10
|
|
|
|
# Your cheese is so fresh most people think it's a cream: Mascarpone
|
|
|
|
# ------------------------------
|
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
|
2013-05-12 03:56:02 +04:00
|
|
|
import platform as plat
|
2010-11-28 23:15:53 +03:00
|
|
|
import re
|
|
|
|
import struct
|
|
|
|
import sys
|
2016-05-04 23:36:08 +03:00
|
|
|
import subprocess
|
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
|
|
|
|
2014-07-01 01:33:41 +04:00
|
|
|
# monkey patch import hook. Even though flake8 says it's not used, it is.
|
2014-08-28 15:44:19 +04:00
|
|
|
# comment this out to disable multi threaded builds.
|
2014-07-01 01:33:41 +04:00
|
|
|
import mp_compile
|
2010-11-28 23:15:53 +03:00
|
|
|
|
2016-03-15 14:16:22 +03:00
|
|
|
_IMAGING = ("decode", "encode", "map", "display", "outline", "path")
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
_LIB_IMAGING = (
|
2014-11-19 13:59:11 +03:00
|
|
|
"Access", "AlphaComposite", "Resample", "Bands", "BitDecode", "Blend",
|
2012-12-04 19:44:26 +04:00
|
|
|
"Chops", "Convert", "ConvertYCbCr", "Copy", "Crc32", "Crop", "Dib", "Draw",
|
2016-03-15 14:16:22 +03:00
|
|
|
"Effects", "EpsEncode", "File", "Fill", "Filter", "FliDecode", "Geometry",
|
|
|
|
"GetBBox", "GifDecode", "GifEncode", "HexDecode", "Histo", "JpegDecode",
|
|
|
|
"JpegEncode", "LzwDecode", "Matrix", "ModeFilter", "MspDecode", "Negative",
|
|
|
|
"Offset", "Pack", "PackDecode", "Palette", "Paste", "Quant", "QuantOctree",
|
|
|
|
"QuantHash", "QuantHeap", "PcdDecode", "PcxDecode", "PcxEncode", "Point",
|
2010-11-28 23:15:53 +03:00
|
|
|
"RankFilter", "RawDecode", "RawEncode", "Storage", "SunRleDecode",
|
|
|
|
"TgaRleDecode", "Unpack", "UnpackYCC", "UnsharpMask", "XbmDecode",
|
2014-03-12 20:25:59 +04:00
|
|
|
"XbmEncode", "ZipDecode", "ZipEncode", "TiffDecode", "Incremental",
|
2016-05-05 22:36:45 +03:00
|
|
|
"Jpeg2KDecode", "Jpeg2KEncode", "BoxBlur", "QuantPngQuant")
|
2010-11-28 23:15:53 +03:00
|
|
|
|
2016-03-30 19:16:10 +03:00
|
|
|
DEBUG = False
|
2010-11-28 23:15:53 +03:00
|
|
|
|
2016-03-30 22:47:27 +03:00
|
|
|
|
2016-03-30 19:16:10 +03:00
|
|
|
def _dbg(s, tp=None):
|
|
|
|
if DEBUG:
|
|
|
|
if tp:
|
|
|
|
print(s % tp)
|
|
|
|
return
|
|
|
|
print(s)
|
|
|
|
|
2010-11-28 23:15:53 +03:00
|
|
|
|
2016-03-30 18:19:23 +03:00
|
|
|
def _add_directory(path, subdir, where=None):
|
|
|
|
if subdir is None:
|
2013-12-11 13:13:06 +04:00
|
|
|
return
|
2016-03-30 18:19:23 +03:00
|
|
|
subdir = os.path.realpath(subdir)
|
|
|
|
if os.path.isdir(subdir) and subdir not in path:
|
2010-11-28 23:15:53 +03:00
|
|
|
if where is None:
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Appending path %s', subdir)
|
2016-03-30 18:19:23 +03:00
|
|
|
path.append(subdir)
|
2010-11-28 23:15:53 +03:00
|
|
|
else:
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Inserting path %s', subdir)
|
2016-03-30 18:19:23 +03:00
|
|
|
path.insert(where, subdir)
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
|
|
|
|
def _find_include_file(self, include):
|
|
|
|
for directory in self.compiler.include_dirs:
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Checking for include file %s in %s', (include, directory))
|
2010-11-28 23:15:53 +03:00
|
|
|
if os.path.isfile(os.path.join(directory, include)):
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Found %s', include)
|
2010-11-28 23:15:53 +03:00
|
|
|
return 1
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
def _find_library_file(self, library):
|
2013-05-12 03:56:02 +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
|
2013-04-24 08:09:32 +04:00
|
|
|
if 'cpython' in self.compiler.shared_lib_extension:
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('stripping cpython from shared library extension %s',
|
|
|
|
self.compiler.shared_lib_extension)
|
2013-04-24 08:09:32 +04:00
|
|
|
existing = self.compiler.shared_lib_extension
|
|
|
|
self.compiler.shared_lib_extension = "." + existing.split('.')[-1]
|
2016-03-15 14:16:22 +03:00
|
|
|
ret = self.compiler.find_library_file(self.compiler.library_dirs,
|
|
|
|
library)
|
2013-04-24 08:09:32 +04:00
|
|
|
self.compiler.shared_lib_extension = existing
|
|
|
|
else:
|
2016-03-30 19:16:10 +03:00
|
|
|
ret = self.compiler.find_library_file(self.compiler.library_dirs,
|
2016-03-30 22:47:27 +03:00
|
|
|
library)
|
2016-03-30 19:16:10 +03:00
|
|
|
if ret:
|
|
|
|
_dbg('Found library %s at %s', (library, ret))
|
|
|
|
else:
|
|
|
|
_dbg("Couldn't find library %s in %s",
|
2016-03-30 22:47:27 +03:00
|
|
|
(library, self.compiler.library_dirs))
|
2016-03-30 19:16:10 +03:00
|
|
|
return ret
|
2013-05-12 03:56:02 +04:00
|
|
|
|
2010-11-28 23:15:53 +03:00
|
|
|
|
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
|
|
|
|
2016-03-15 14:16:22 +03:00
|
|
|
|
2010-11-28 23:15:53 +03:00
|
|
|
try:
|
|
|
|
import _tkinter
|
2014-03-27 00:12:20 +04:00
|
|
|
except (ImportError, OSError):
|
|
|
|
# pypy emits an oserror
|
2010-11-28 23:15:53 +03:00
|
|
|
_tkinter = None
|
|
|
|
|
2010-11-28 23:31:09 +03:00
|
|
|
NAME = 'Pillow'
|
2016-04-01 17:39:35 +03:00
|
|
|
PILLOW_VERSION = '3.3.0.dev0'
|
2010-11-28 23:15:53 +03:00
|
|
|
TCL_ROOT = None
|
|
|
|
JPEG_ROOT = None
|
2014-03-14 18:35:09 +04:00
|
|
|
JPEG2K_ROOT = None
|
2010-11-28 23:15:53 +03:00
|
|
|
ZLIB_ROOT = None
|
2016-05-05 22:36:45 +03:00
|
|
|
IMAGEQUANT_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):
|
2013-05-31 02:04:34 +04:00
|
|
|
class feature:
|
2016-03-30 22:47:27 +03:00
|
|
|
features = ['zlib', 'jpeg', 'tiff', 'freetype', 'tcl', 'tk', 'lcms',
|
2016-05-05 22:36:45 +03:00
|
|
|
'webp', 'webpmux', 'jpeg2000', 'imagequant']
|
2016-03-30 18:20:27 +03:00
|
|
|
|
2015-09-22 23:07:31 +03:00
|
|
|
required = set(['jpeg', 'zlib'])
|
2013-05-31 02:04:34 +04:00
|
|
|
|
2016-03-30 18:20:27 +03:00
|
|
|
def __init__(self):
|
|
|
|
for f in self.features:
|
|
|
|
setattr(self, f, None)
|
|
|
|
|
2013-05-31 02:08:04 +04:00
|
|
|
def require(self, feat):
|
|
|
|
return feat in self.required
|
2014-06-24 10:34:05 +04:00
|
|
|
|
2013-06-08 10:14:44 +04:00
|
|
|
def want(self, feat):
|
|
|
|
return getattr(self, feat) is None
|
|
|
|
|
2013-05-31 02:04:34 +04:00
|
|
|
def __iter__(self):
|
2016-03-30 18:20:27 +03:00
|
|
|
for x in self.features:
|
|
|
|
yield x
|
2013-05-31 02:04:34 +04:00
|
|
|
|
|
|
|
feature = feature()
|
|
|
|
|
|
|
|
user_options = build_ext.user_options + [
|
2016-03-15 14:16:22 +03:00
|
|
|
('disable-%s' % x, None, 'Disable support for %s' % x) for x in feature
|
2013-05-31 02:08:04 +04:00
|
|
|
] + [
|
2016-03-15 14:16:22 +03:00
|
|
|
('enable-%s' % x, None, 'Enable support for %s' % x) for x in feature
|
2016-04-25 18:03:36 +03:00
|
|
|
] + [
|
|
|
|
('disable-platform-guessing', None, 'Disable platform guessing on Linux'),
|
2016-05-03 22:26:58 +03:00
|
|
|
('disable-osx-tcltk-framework', None,
|
|
|
|
'Disable linking against system tcl/tk frameworks on OSX'),
|
2016-04-25 18:03:36 +03:00
|
|
|
('debug', None, 'Debug logging')
|
|
|
|
]
|
2013-05-31 02:04:34 +04:00
|
|
|
|
|
|
|
def initialize_options(self):
|
2016-04-25 18:03:36 +03:00
|
|
|
self.disable_platform_guessing = None
|
2016-05-03 22:26:58 +03:00
|
|
|
self.disable_osx_tcltk_framework = None
|
2013-05-31 02:04:34 +04:00
|
|
|
build_ext.initialize_options(self)
|
|
|
|
for x in self.feature:
|
|
|
|
setattr(self, 'disable_%s' % x, None)
|
2013-05-31 02:08:04 +04:00
|
|
|
setattr(self, 'enable_%s' % x, None)
|
2013-05-31 02:04:34 +04:00
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
build_ext.finalize_options(self)
|
2016-03-30 19:16:10 +03:00
|
|
|
if self.debug:
|
|
|
|
global DEBUG
|
|
|
|
DEBUG = True
|
2013-05-31 02:04:34 +04:00
|
|
|
for x in self.feature:
|
|
|
|
if getattr(self, 'disable_%s' % x):
|
|
|
|
setattr(self.feature, x, False)
|
2015-09-22 23:07:31 +03:00
|
|
|
self.feature.required.discard(x)
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Disabling %s', x)
|
2013-05-31 02:08:04 +04:00
|
|
|
if getattr(self, 'enable_%s' % x):
|
|
|
|
raise ValueError(
|
2016-03-15 14:16:22 +03:00
|
|
|
'Conflicting options: --enable-%s and --disable-%s' %
|
|
|
|
(x, x))
|
2013-05-31 02:08:04 +04:00
|
|
|
if getattr(self, 'enable_%s' % x):
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Requiring %s', x)
|
2015-09-22 23:07:31 +03:00
|
|
|
self.feature.required.add(x)
|
2013-05-31 02:04:34 +04:00
|
|
|
|
2010-11-28 23:15:53 +03:00
|
|
|
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
|
|
|
|
|
2014-03-14 18:35:09 +04:00
|
|
|
for root in (TCL_ROOT, JPEG_ROOT, JPEG2K_ROOT, TIFF_ROOT, ZLIB_ROOT,
|
2016-05-05 22:36:45 +03:00
|
|
|
FREETYPE_ROOT, LCMS_ROOT, IMAGEQUANT_ROOT):
|
2013-01-09 15:48:06 +04:00
|
|
|
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)
|
|
|
|
|
2013-12-11 13:04:24 +04:00
|
|
|
# respect CFLAGS/LDFLAGS
|
|
|
|
for k in ('CFLAGS', 'LDFLAGS'):
|
|
|
|
if k in os.environ:
|
|
|
|
for match in re.finditer(r'-I([^\s]+)', os.environ[k]):
|
|
|
|
_add_directory(include_dirs, match.group(1))
|
|
|
|
for match in re.finditer(r'-L([^\s]+)', os.environ[k]):
|
|
|
|
_add_directory(library_dirs, match.group(1))
|
|
|
|
|
|
|
|
# include, rpath, if set as environment variables:
|
|
|
|
for k in ('C_INCLUDE_PATH', 'CPATH', 'INCLUDE'):
|
|
|
|
if k in os.environ:
|
|
|
|
for d in os.environ[k].split(os.path.pathsep):
|
|
|
|
_add_directory(include_dirs, d)
|
|
|
|
|
|
|
|
for k in ('LD_RUN_PATH', 'LIBRARY_PATH', 'LIB'):
|
|
|
|
if k in os.environ:
|
|
|
|
for d in os.environ[k].split(os.path.pathsep):
|
|
|
|
_add_directory(library_dirs, d)
|
|
|
|
|
|
|
|
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"))
|
|
|
|
|
2010-11-28 23:15:53 +03:00
|
|
|
#
|
|
|
|
# add platform directories
|
|
|
|
|
2016-05-01 12:57:50 +03:00
|
|
|
if self.disable_platform_guessing:
|
|
|
|
pass
|
|
|
|
|
|
|
|
elif sys.platform == "cygwin":
|
2010-11-28 23:15:53 +03:00
|
|
|
# pythonX.Y.dll.a is in the /usr/lib/pythonX.Y/config directory
|
2016-03-15 14:16:22 +03:00
|
|
|
_add_directory(library_dirs,
|
|
|
|
os.path.join("/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")
|
2014-05-10 19:11:04 +04:00
|
|
|
|
|
|
|
# if Homebrew is installed, use its lib and include directories
|
2013-10-02 19:36:47 +04:00
|
|
|
try:
|
2016-03-15 14:16:22 +03:00
|
|
|
prefix = subprocess.check_output(['brew', '--prefix']).strip(
|
|
|
|
).decode('latin1')
|
2013-10-02 19:36:47 +04:00
|
|
|
except:
|
2014-05-10 19:11:04 +04:00
|
|
|
# Homebrew not installed
|
|
|
|
prefix = None
|
|
|
|
|
|
|
|
ft_prefix = None
|
|
|
|
|
|
|
|
if prefix:
|
|
|
|
# add Homebrew's include and lib directories
|
|
|
|
_add_directory(library_dirs, os.path.join(prefix, 'lib'))
|
|
|
|
_add_directory(include_dirs, os.path.join(prefix, 'include'))
|
|
|
|
ft_prefix = os.path.join(prefix, 'opt', 'freetype')
|
|
|
|
|
|
|
|
if ft_prefix and os.path.isdir(ft_prefix):
|
|
|
|
# freetype might not be linked into Homebrew's prefix
|
|
|
|
_add_directory(library_dirs, os.path.join(ft_prefix, 'lib'))
|
2016-03-15 14:16:22 +03:00
|
|
|
_add_directory(include_dirs,
|
|
|
|
os.path.join(ft_prefix, 'include'))
|
2014-05-10 19:11:04 +04:00
|
|
|
else:
|
2014-06-24 10:34:05 +04:00
|
|
|
# fall back to freetype from XQuartz if
|
|
|
|
# Homebrew's freetype is missing
|
2014-05-10 19:11:04 +04:00
|
|
|
_add_directory(library_dirs, "/usr/X11/lib")
|
|
|
|
_add_directory(include_dirs, "/usr/X11/include")
|
2013-12-11 12:56:40 +04:00
|
|
|
|
2011-09-07 18:08:35 +04:00
|
|
|
elif sys.platform.startswith("linux"):
|
2014-03-31 22:59:29 +04:00
|
|
|
arch_tp = (plat.processor(), plat.architecture()[0])
|
2014-06-24 10:34:05 +04:00
|
|
|
if arch_tp == ("x86_64", "32bit"):
|
2015-10-14 16:49:03 +03:00
|
|
|
# 32-bit build on 64-bit machine.
|
2014-03-31 22:59:29 +04:00
|
|
|
_add_directory(library_dirs, "/usr/lib/i386-linux-gnu")
|
2013-02-18 20:16:13 +04:00
|
|
|
else:
|
2014-03-31 22:59:29 +04:00
|
|
|
for platform_ in arch_tp:
|
|
|
|
|
|
|
|
if not platform_:
|
|
|
|
continue
|
|
|
|
|
|
|
|
if platform_ in ["x86_64", "64bit"]:
|
|
|
|
_add_directory(library_dirs, "/lib64")
|
|
|
|
_add_directory(library_dirs, "/usr/lib64")
|
2016-03-15 14:16:22 +03:00
|
|
|
_add_directory(library_dirs,
|
|
|
|
"/usr/lib/x86_64-linux-gnu")
|
2014-03-31 22:59:29 +04:00
|
|
|
break
|
|
|
|
elif platform_ in ["i386", "i686", "32bit"]:
|
2016-03-15 14:16:22 +03:00
|
|
|
_add_directory(library_dirs, "/usr/lib/i386-linux-gnu")
|
2014-03-31 22:59:29 +04:00
|
|
|
break
|
|
|
|
elif platform_ in ["aarch64"]:
|
|
|
|
_add_directory(library_dirs, "/usr/lib64")
|
2016-03-15 14:16:22 +03:00
|
|
|
_add_directory(library_dirs,
|
|
|
|
"/usr/lib/aarch64-linux-gnu")
|
2014-03-31 22:59:29 +04:00
|
|
|
break
|
|
|
|
elif platform_ in ["arm", "armv7l"]:
|
2016-03-15 14:16:22 +03:00
|
|
|
_add_directory(library_dirs,
|
|
|
|
"/usr/lib/arm-linux-gnueabi")
|
2014-03-31 22:59:29 +04:00
|
|
|
break
|
|
|
|
elif platform_ in ["ppc64"]:
|
|
|
|
_add_directory(library_dirs, "/usr/lib64")
|
2016-03-15 14:16:22 +03:00
|
|
|
_add_directory(library_dirs,
|
|
|
|
"/usr/lib/ppc64-linux-gnu")
|
|
|
|
_add_directory(library_dirs,
|
|
|
|
"/usr/lib/powerpc64-linux-gnu")
|
2014-03-31 22:59:29 +04:00
|
|
|
break
|
|
|
|
elif platform_ in ["ppc"]:
|
|
|
|
_add_directory(library_dirs, "/usr/lib/ppc-linux-gnu")
|
2016-03-15 14:16:22 +03:00
|
|
|
_add_directory(library_dirs,
|
|
|
|
"/usr/lib/powerpc-linux-gnu")
|
2014-03-31 22:59:29 +04:00
|
|
|
break
|
|
|
|
elif platform_ in ["s390x"]:
|
|
|
|
_add_directory(library_dirs, "/usr/lib64")
|
2016-03-15 14:16:22 +03:00
|
|
|
_add_directory(library_dirs,
|
|
|
|
"/usr/lib/s390x-linux-gnu")
|
2014-03-31 22:59:29 +04:00
|
|
|
break
|
|
|
|
elif platform_ in ["s390"]:
|
|
|
|
_add_directory(library_dirs, "/usr/lib/s390-linux-gnu")
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
raise ValueError(
|
|
|
|
"Unable to identify Linux platform: `%s`" % platform_)
|
2011-05-31 19:24:38 +04:00
|
|
|
|
2016-04-25 18:03:36 +03:00
|
|
|
# XXX Kludge. Above /\ we brute force support multiarch. Here we
|
|
|
|
# try Barry's more general approach. Afterward, something should
|
|
|
|
# work ;-)
|
|
|
|
self.add_multiarch_paths()
|
2010-11-28 23:15:53 +03:00
|
|
|
|
2014-02-01 15:06:21 +04:00
|
|
|
elif sys.platform.startswith("gnu"):
|
|
|
|
self.add_multiarch_paths()
|
|
|
|
|
2015-12-27 22:43:27 +03:00
|
|
|
elif sys.platform.startswith("freebsd"):
|
|
|
|
_add_directory(library_dirs, "/usr/local/lib")
|
|
|
|
_add_directory(include_dirs, "/usr/local/include")
|
|
|
|
|
2013-11-14 16:10:19 +04:00
|
|
|
elif sys.platform.startswith("netbsd"):
|
2015-07-28 12:59:52 +03:00
|
|
|
_add_directory(library_dirs, "/usr/pkg/lib")
|
|
|
|
_add_directory(include_dirs, "/usr/pkg/include")
|
2013-11-14 16:10:19 +04:00
|
|
|
|
2015-07-27 19:17:49 +03:00
|
|
|
elif sys.platform.startswith("sunos5"):
|
2016-03-15 14:16:22 +03:00
|
|
|
_add_directory(library_dirs, "/opt/local/lib")
|
|
|
|
_add_directory(include_dirs, "/opt/local/include")
|
2015-09-11 12:28:19 +03:00
|
|
|
|
2010-11-28 23:15:53 +03:00
|
|
|
# FIXME: check /opt/stuff directories here?
|
|
|
|
|
|
|
|
# locate tkinter libraries
|
|
|
|
|
|
|
|
if _tkinter:
|
|
|
|
TCL_VERSION = _tkinter.TCL_VERSION[:3]
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Tkinter found, will check for Tcl/Tk')
|
|
|
|
else:
|
|
|
|
_dbg('Tkinter not found')
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
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"),
|
2016-03-15 14:16:22 +03:00
|
|
|
"/Tcl",
|
|
|
|
"/Tcl" + TCLVERSION,
|
|
|
|
"/Tcl" + TCL_VERSION,
|
|
|
|
os.path.join(
|
|
|
|
os.environ.get("ProgramFiles", ""), "Tcl"),
|
|
|
|
]
|
2010-11-28 23:15:53 +03:00
|
|
|
for TCL_ROOT in roots:
|
|
|
|
TCL_ROOT = os.path.abspath(TCL_ROOT)
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Checking %s for tk.h', TCL_ROOT)
|
2010-11-28 23:15:53 +03:00
|
|
|
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
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Tcl/tk not found')
|
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:
|
2016-04-25 18:03:36 +03:00
|
|
|
if not self.disable_platform_guessing:
|
|
|
|
tcl_dir = "/usr/include/tcl" + TCL_VERSION
|
|
|
|
if os.path.isfile(os.path.join(tcl_dir, "tk.h")):
|
|
|
|
_add_directory(include_dirs, tcl_dir)
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
# standard locations
|
2016-04-25 18:03:36 +03:00
|
|
|
if not self.disable_platform_guessing:
|
|
|
|
_add_directory(library_dirs, "/usr/local/lib")
|
|
|
|
_add_directory(include_dirs, "/usr/local/include")
|
2010-11-28 23:15:53 +03:00
|
|
|
|
2016-04-25 18:03:36 +03:00
|
|
|
_add_directory(library_dirs, "/usr/lib")
|
|
|
|
_add_directory(include_dirs, "/usr/include")
|
2016-05-30 16:28:08 +03:00
|
|
|
# alpine, at least
|
|
|
|
_add_directory(library_dirs, "/lib")
|
2010-11-28 23:15:53 +03:00
|
|
|
|
2014-03-14 18:35:09 +04:00
|
|
|
# on Windows, look for the OpenJPEG libraries in the location that
|
2014-05-27 15:43:54 +04:00
|
|
|
# the official installer puts them
|
2014-03-14 18:35:09 +04:00
|
|
|
if sys.platform == "win32":
|
2014-05-27 15:43:54 +04:00
|
|
|
program_files = os.environ.get('ProgramFiles', '')
|
|
|
|
best_version = (0, 0)
|
|
|
|
best_path = None
|
|
|
|
for name in os.listdir(program_files):
|
|
|
|
if name.startswith('OpenJPEG '):
|
2016-03-15 14:16:22 +03:00
|
|
|
version = tuple([int(x) for x in name[9:].strip().split(
|
|
|
|
'.')])
|
2014-05-27 15:43:54 +04:00
|
|
|
if version > best_version:
|
|
|
|
best_version = version
|
|
|
|
best_path = os.path.join(program_files, name)
|
|
|
|
|
|
|
|
if best_path:
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Adding %s to search list', best_path)
|
2016-03-15 14:16:22 +03:00
|
|
|
_add_directory(library_dirs, os.path.join(best_path, 'lib'))
|
2014-05-27 15:43:54 +04:00
|
|
|
_add_directory(include_dirs,
|
|
|
|
os.path.join(best_path, 'include'))
|
2014-03-14 18:35:09 +04:00
|
|
|
|
2010-11-28 23:15:53 +03:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
2013-05-31 02:04:34 +04:00
|
|
|
feature = self.feature
|
|
|
|
|
2013-06-08 10:14:44 +04:00
|
|
|
if feature.want('zlib'):
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Looking for zlib')
|
2013-05-31 02:04:34 +04:00
|
|
|
if _find_include_file(self, "zlib.h"):
|
|
|
|
if _find_library_file(self, "z"):
|
|
|
|
feature.zlib = "z"
|
2014-06-24 10:34:05 +04:00
|
|
|
elif (sys.platform == "win32" and
|
2016-03-15 14:16:22 +03:00
|
|
|
_find_library_file(self, "zlib")):
|
2013-05-31 02:04:34 +04:00
|
|
|
feature.zlib = "zlib" # alternative name
|
|
|
|
|
2013-06-08 10:14:44 +04:00
|
|
|
if feature.want('jpeg'):
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Looking for jpeg')
|
2013-05-31 02:04:34 +04:00
|
|
|
if _find_include_file(self, "jpeglib.h"):
|
|
|
|
if _find_library_file(self, "jpeg"):
|
|
|
|
feature.jpeg = "jpeg"
|
2016-03-15 14:16:22 +03:00
|
|
|
elif (sys.platform == "win32" and
|
|
|
|
_find_library_file(self, "libjpeg")):
|
2013-05-31 02:04:34 +04:00
|
|
|
feature.jpeg = "libjpeg" # alternative name
|
|
|
|
|
2014-05-31 02:47:27 +04:00
|
|
|
feature.openjpeg_version = None
|
2014-03-12 20:25:59 +04:00
|
|
|
if feature.want('jpeg2000'):
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Looking for jpeg2000')
|
2014-05-27 15:43:54 +04:00
|
|
|
best_version = None
|
|
|
|
best_path = None
|
2014-06-24 10:34:05 +04:00
|
|
|
|
2014-05-27 15:43:54 +04:00
|
|
|
# Find the best version
|
|
|
|
for directory in self.compiler.include_dirs:
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Checking for openjpeg-#.# in %s', directory)
|
2014-06-29 03:15:06 +04:00
|
|
|
try:
|
|
|
|
listdir = os.listdir(directory)
|
2014-08-28 15:44:19 +04:00
|
|
|
except Exception:
|
2014-06-29 03:15:06 +04:00
|
|
|
# WindowsError, FileNotFoundError
|
|
|
|
continue
|
|
|
|
for name in listdir:
|
2014-05-27 15:43:54 +04:00
|
|
|
if name.startswith('openjpeg-') and \
|
|
|
|
os.path.isfile(os.path.join(directory, name,
|
|
|
|
'openjpeg.h')):
|
2016-03-30 22:47:27 +03:00
|
|
|
_dbg('Found openjpeg.h in %s/%s', (directory, name))
|
2014-05-27 15:43:54 +04:00
|
|
|
version = tuple([int(x) for x in name[9:].split('.')])
|
|
|
|
if best_version is None or version > best_version:
|
|
|
|
best_version = version
|
|
|
|
best_path = os.path.join(directory, name)
|
2016-03-30 22:47:27 +03:00
|
|
|
_dbg('Best openjpeg version %s so far in %s',
|
|
|
|
(best_version, best_path))
|
2014-05-27 15:43:54 +04:00
|
|
|
|
|
|
|
if best_version and _find_library_file(self, 'openjp2'):
|
|
|
|
# Add the directory to the include path so we can include
|
|
|
|
# <openjpeg.h> rather than having to cope with the versioned
|
|
|
|
# include path
|
|
|
|
_add_directory(self.compiler.include_dirs, best_path, 0)
|
|
|
|
feature.jpeg2000 = 'openjp2'
|
2016-03-15 14:16:22 +03:00
|
|
|
feature.openjpeg_version = '.'.join([str(x) for x in
|
|
|
|
best_version])
|
2014-06-24 10:34:05 +04:00
|
|
|
|
2016-05-05 22:36:45 +03:00
|
|
|
if feature.want('imagequant'):
|
|
|
|
_dbg('Looking for imagequant')
|
|
|
|
if _find_include_file(self, 'libimagequant.h'):
|
|
|
|
if _find_library_file(self, "imagequant"):
|
|
|
|
feature.imagequant = "imagequant"
|
|
|
|
elif _find_library_file(self, "libimagequant"):
|
|
|
|
feature.imagequant = "libimagequant"
|
|
|
|
|
2013-06-08 10:14:44 +04:00
|
|
|
if feature.want('tiff'):
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Looking for tiff')
|
|
|
|
if _find_include_file(self, 'tiff.h'):
|
|
|
|
if _find_library_file(self, "tiff"):
|
|
|
|
feature.tiff = "tiff"
|
|
|
|
if sys.platform == "win32" and _find_library_file(self, "libtiff"):
|
|
|
|
feature.tiff = "libtiff"
|
|
|
|
if (sys.platform == "darwin" and
|
|
|
|
_find_library_file(self, "libtiff")):
|
|
|
|
feature.tiff = "libtiff"
|
2013-05-31 02:04:34 +04:00
|
|
|
|
2013-06-08 10:14:44 +04:00
|
|
|
if feature.want('freetype'):
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Looking for freetype')
|
2013-05-31 02:04:34 +04:00
|
|
|
if _find_library_file(self, "freetype"):
|
|
|
|
# look for freetype2 include files
|
|
|
|
freetype_version = 0
|
2016-03-30 18:19:23 +03:00
|
|
|
for subdir in self.compiler.include_dirs:
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Checking for include file %s in %s', ("ft2build.h", subdir))
|
2016-03-30 18:19:23 +03:00
|
|
|
if os.path.isfile(os.path.join(subdir, "ft2build.h")):
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Found %s in %s', ("ft2build.h", subdir))
|
2013-05-31 02:04:34 +04:00
|
|
|
freetype_version = 21
|
2016-03-30 18:19:23 +03:00
|
|
|
subdir = os.path.join(subdir, "freetype2")
|
2013-05-31 02:04:34 +04:00
|
|
|
break
|
2016-03-30 18:19:23 +03:00
|
|
|
subdir = os.path.join(subdir, "freetype2")
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Checking for include file %s in %s', ("ft2build.h", subdir))
|
2016-03-30 18:19:23 +03:00
|
|
|
if os.path.isfile(os.path.join(subdir, "ft2build.h")):
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Found %s in %s', ("ft2build.h", subdir))
|
2013-05-31 02:04:34 +04:00
|
|
|
freetype_version = 21
|
|
|
|
break
|
|
|
|
if freetype_version:
|
|
|
|
feature.freetype = "freetype"
|
|
|
|
feature.freetype_version = freetype_version
|
2016-03-30 18:19:23 +03:00
|
|
|
if subdir:
|
|
|
|
_add_directory(self.compiler.include_dirs, subdir, 0)
|
2013-05-31 02:04:34 +04:00
|
|
|
|
2013-06-08 10:14:44 +04:00
|
|
|
if feature.want('lcms'):
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Looking for lcms')
|
2013-10-02 10:05:56 +04:00
|
|
|
if _find_include_file(self, "lcms2.h"):
|
|
|
|
if _find_library_file(self, "lcms2"):
|
2014-08-23 03:14:19 +04:00
|
|
|
feature.lcms = "lcms2"
|
|
|
|
elif _find_library_file(self, "lcms2_static"):
|
2015-07-08 08:32:50 +03:00
|
|
|
# alternate Windows name.
|
2014-08-23 03:14:19 +04:00
|
|
|
feature.lcms = "lcms2_static"
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
if _tkinter and _find_include_file(self, "tk.h"):
|
2015-07-08 07:04:02 +03:00
|
|
|
# the library names may vary somewhat (e.g. tcl85 or tcl8.5)
|
2010-11-28 23:15:53 +03:00
|
|
|
version = TCL_VERSION[0] + TCL_VERSION[2]
|
2013-06-08 10:14:44 +04:00
|
|
|
if feature.want('tcl'):
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Looking for TCL')
|
2013-05-31 02:04:34 +04:00
|
|
|
if _find_library_file(self, "tcl" + version):
|
|
|
|
feature.tcl = "tcl" + version
|
|
|
|
elif _find_library_file(self, "tcl" + TCL_VERSION):
|
|
|
|
feature.tcl = "tcl" + TCL_VERSION
|
2013-06-08 10:14:44 +04:00
|
|
|
if feature.want('tk'):
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Looking for TK')
|
2013-05-31 02:04:34 +04:00
|
|
|
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-06-08 10:14:44 +04:00
|
|
|
if feature.want('webp'):
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Looking for webp')
|
2013-05-31 02:04:34 +04:00
|
|
|
if (_find_include_file(self, "webp/encode.h") and
|
|
|
|
_find_include_file(self, "webp/decode.h")):
|
2014-06-24 10:34:05 +04:00
|
|
|
# In Google's precompiled zip it is call "libwebp":
|
|
|
|
if _find_library_file(self, "webp"):
|
2013-05-31 02:04:34 +04:00
|
|
|
feature.webp = "webp"
|
2014-08-23 04:04:26 +04:00
|
|
|
elif _find_library_file(self, "libwebp"):
|
|
|
|
feature.webp = "libwebp"
|
2013-03-12 18:30:59 +04:00
|
|
|
|
2013-07-05 00:57:05 +04:00
|
|
|
if feature.want('webpmux'):
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Looking for webpmux')
|
2013-07-05 00:57:05 +04:00
|
|
|
if (_find_include_file(self, "webp/mux.h") and
|
|
|
|
_find_include_file(self, "webp/demux.h")):
|
2014-06-24 10:34:05 +04:00
|
|
|
if (_find_library_file(self, "webpmux") and
|
|
|
|
_find_library_file(self, "webpdemux")):
|
2013-07-05 00:57:05 +04:00
|
|
|
feature.webpmux = "webpmux"
|
2014-08-23 04:04:26 +04:00
|
|
|
if (_find_library_file(self, "libwebpmux") and
|
|
|
|
_find_library_file(self, "libwebpdemux")):
|
|
|
|
feature.webpmux = "libwebpmux"
|
2013-07-05 00:57:05 +04:00
|
|
|
|
2013-05-31 02:08:04 +04:00
|
|
|
for f in feature:
|
|
|
|
if not getattr(feature, f) and feature.require(f):
|
2016-03-08 21:30:37 +03:00
|
|
|
if f in ('jpeg', 'zlib'):
|
2016-03-15 14:16:22 +03:00
|
|
|
raise ValueError(
|
|
|
|
'%s is required unless explicitly disabled'
|
|
|
|
' using --disable-%s, aborting' % (f, f))
|
2013-05-31 02:08:04 +04:00
|
|
|
raise ValueError(
|
2016-03-15 14:16:22 +03:00
|
|
|
'--enable-%s requested but %s not found, aborting.' %
|
|
|
|
(f, f))
|
2013-05-31 02:08:04 +04:00
|
|
|
|
2010-11-28 23:15:53 +03:00
|
|
|
#
|
|
|
|
# core library
|
|
|
|
|
|
|
|
files = ["_imaging.c"]
|
2016-03-30 19:13:10 +03:00
|
|
|
for src_file in _IMAGING:
|
|
|
|
files.append(src_file + ".c")
|
|
|
|
for src_file in _LIB_IMAGING:
|
|
|
|
files.append(os.path.join("libImaging", src_file + ".c"))
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
libs = []
|
|
|
|
defs = []
|
|
|
|
if feature.jpeg:
|
|
|
|
libs.append(feature.jpeg)
|
|
|
|
defs.append(("HAVE_LIBJPEG", None))
|
2014-03-12 20:25:59 +04:00
|
|
|
if feature.jpeg2000:
|
|
|
|
libs.append(feature.jpeg2000)
|
|
|
|
defs.append(("HAVE_OPENJPEG", None))
|
2014-03-29 07:29:58 +04:00
|
|
|
if sys.platform == "win32":
|
|
|
|
defs.append(("OPJ_STATIC", None))
|
2010-11-28 23:15:53 +03:00
|
|
|
if feature.zlib:
|
|
|
|
libs.append(feature.zlib)
|
|
|
|
defs.append(("HAVE_LIBZ", None))
|
2016-05-05 22:36:45 +03:00
|
|
|
if feature.imagequant:
|
|
|
|
libs.append(feature.imagequant)
|
|
|
|
defs.append(("HAVE_LIBIMAGEQUANT", 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))
|
|
|
|
|
2016-03-15 14:16:22 +03:00
|
|
|
exts = [(Extension("PIL._imaging",
|
|
|
|
files,
|
|
|
|
libraries=libs,
|
|
|
|
define_macros=defs))]
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
#
|
|
|
|
# additional libraries
|
|
|
|
|
|
|
|
if feature.freetype:
|
2016-03-15 14:16:22 +03:00
|
|
|
exts.append(Extension("PIL._imagingft",
|
|
|
|
["_imagingft.c"],
|
|
|
|
libraries=["freetype"]))
|
2010-11-28 23:15:53 +03:00
|
|
|
|
2016-03-30 19:16:10 +03:00
|
|
|
if feature.lcms:
|
2010-11-28 23:15:53 +03:00
|
|
|
extra = []
|
|
|
|
if sys.platform == "win32":
|
|
|
|
extra.extend(["user32", "gdi32"])
|
2016-03-15 14:16:22 +03:00
|
|
|
exts.append(Extension("PIL._imagingcms",
|
|
|
|
["_imagingcms.c"],
|
|
|
|
libraries=[feature.lcms] + extra))
|
2010-11-28 23:15:53 +03:00
|
|
|
|
2016-03-30 19:16:10 +03:00
|
|
|
if feature.webp:
|
2014-08-23 04:04:26 +04:00
|
|
|
libs = [feature.webp]
|
2013-07-05 00:57:05 +04:00
|
|
|
defs = []
|
|
|
|
|
|
|
|
if feature.webpmux:
|
|
|
|
defs.append(("HAVE_WEBPMUX", None))
|
2014-08-23 04:04:26 +04:00
|
|
|
libs.append(feature.webpmux)
|
2015-04-24 03:15:14 +03:00
|
|
|
libs.append(feature.webpmux.replace('pmux', 'pdemux'))
|
2013-07-05 00:57:05 +04:00
|
|
|
|
2016-03-15 14:16:22 +03:00
|
|
|
exts.append(Extension("PIL._webp",
|
|
|
|
["_webp.c"],
|
|
|
|
libraries=libs,
|
|
|
|
define_macros=defs))
|
2013-03-12 18:30:59 +04:00
|
|
|
|
2015-07-08 08:32:24 +03:00
|
|
|
if feature.tcl and feature.tk:
|
2016-05-03 22:26:58 +03:00
|
|
|
if sys.platform == "darwin" and not self.disable_osx_tcltk_framework:
|
2015-07-08 08:32:24 +03:00
|
|
|
# locate Tcl/Tk frameworks
|
|
|
|
frameworks = []
|
|
|
|
framework_roots = [
|
2016-03-15 14:16:22 +03:00
|
|
|
"/Library/Frameworks", "/System/Library/Frameworks"
|
|
|
|
]
|
2016-03-30 19:16:10 +03:00
|
|
|
_dbg('Looking for TclTk Framework Build')
|
2015-07-08 08:32:24 +03:00
|
|
|
for root in framework_roots:
|
|
|
|
root_tcl = os.path.join(root, "Tcl.framework")
|
|
|
|
root_tk = os.path.join(root, "Tk.framework")
|
|
|
|
if (os.path.exists(root_tcl) and os.path.exists(root_tk)):
|
|
|
|
print("--- using frameworks at %s" % root)
|
|
|
|
frameworks = ["-framework", "Tcl", "-framework", "Tk"]
|
2016-03-30 18:19:23 +03:00
|
|
|
subdir = os.path.join(root_tcl, "Headers")
|
|
|
|
_add_directory(self.compiler.include_dirs, subdir, 0)
|
|
|
|
subdir = os.path.join(root_tk, "Headers")
|
|
|
|
_add_directory(self.compiler.include_dirs, subdir, 1)
|
2015-07-08 08:32:24 +03:00
|
|
|
break
|
|
|
|
if frameworks:
|
2016-03-15 14:16:22 +03:00
|
|
|
exts.append(Extension("PIL._imagingtk",
|
|
|
|
["_imagingtk.c", "Tk/tkImaging.c"],
|
|
|
|
extra_compile_args=frameworks,
|
|
|
|
extra_link_args=frameworks))
|
2015-07-08 08:32:24 +03:00
|
|
|
else:
|
2016-03-15 14:16:22 +03:00
|
|
|
exts.append(Extension("PIL._imagingtk",
|
|
|
|
["_imagingtk.c", "Tk/tkImaging.c"],
|
|
|
|
libraries=[feature.tcl, feature.tk]))
|
2010-11-28 23:15:53 +03:00
|
|
|
|
2016-03-30 19:16:10 +03:00
|
|
|
exts.append(Extension("PIL._imagingmath", ["_imagingmath.c"]))
|
|
|
|
exts.append(Extension("PIL._imagingmorph", ["_imagingmorph.c"]))
|
2014-06-05 00:03:00 +04:00
|
|
|
|
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-12 04:12:27 +04:00
|
|
|
print("PIL SETUP SUMMARY")
|
2012-06-12 09:13:40 +04:00
|
|
|
print("-" * 68)
|
2014-07-01 15:39:03 +04:00
|
|
|
print("version Pillow %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"),
|
2014-06-24 10:34:05 +04:00
|
|
|
(feature.jpeg2000, "OPENJPEG (JPEG2000)",
|
2016-03-15 14:16:22 +03:00
|
|
|
feature.openjpeg_version),
|
2010-11-28 23:15:53 +03:00
|
|
|
(feature.zlib, "ZLIB (PNG/ZIP)"),
|
2016-05-05 22:36:45 +03:00
|
|
|
(feature.imagequant, "LIBIMAGEQUANT"),
|
2013-12-30 07:10:49 +04:00
|
|
|
(feature.tiff, "LIBTIFF"),
|
2010-11-28 23:15:53 +03:00
|
|
|
(feature.freetype, "FREETYPE2"),
|
2013-10-02 10:05:56 +04:00
|
|
|
(feature.lcms, "LITTLECMS2"),
|
2013-07-05 00:57:05 +04:00
|
|
|
(feature.webp, "WEBP"),
|
2016-03-15 14:16:22 +03:00
|
|
|
(feature.webpmux, "WEBPMUX"),
|
|
|
|
]
|
2010-11-28 23:15:53 +03:00
|
|
|
|
|
|
|
all = 1
|
|
|
|
for option in options:
|
|
|
|
if option[0]:
|
2014-05-27 15:43:54 +04:00
|
|
|
version = ''
|
2014-05-31 02:08:21 +04:00
|
|
|
if len(option) >= 3 and option[2]:
|
2014-05-27 15:43:54 +04:00
|
|
|
version = ' (%s)' % option[2]
|
|
|
|
print("--- %s support available%s" % (option[1], version))
|
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")
|
2016-03-30 19:16:10 +03:00
|
|
|
print("library and headers.")
|
2016-04-28 09:35:03 +03:00
|
|
|
print("See https://pillow.readthedocs.io/en/latest/installation.html#building-from-source")
|
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
|
2016-03-30 18:19:23 +03:00
|
|
|
for subdir in include_dirs:
|
|
|
|
zlibfile = os.path.join(subdir, "zlib.h")
|
2010-11-28 23:15:53 +03:00
|
|
|
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
|
|
|
|
2016-04-15 18:09:46 +03:00
|
|
|
# https://hg.python.org/users/barry/rev/7e8deab93d5a
|
2011-05-31 19:24:38 +04:00
|
|
|
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)
|
2016-05-04 23:36:08 +03:00
|
|
|
with open(tmpfile, 'wb') as fp:
|
2016-05-30 16:28:08 +03:00
|
|
|
try:
|
|
|
|
ret = subprocess.call(['dpkg-architecture',
|
|
|
|
'-qDEB_HOST_MULTIARCH'], stdout=fp)
|
|
|
|
except:
|
|
|
|
return
|
2011-05-31 19:24:38 +04:00
|
|
|
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()
|
2014-08-11 10:14:07 +04:00
|
|
|
fp.close()
|
2016-03-15 14:16:22 +03:00
|
|
|
_add_directory(self.compiler.library_dirs,
|
|
|
|
'/usr/lib/' + multiarch_path_component)
|
|
|
|
_add_directory(self.compiler.include_dirs,
|
|
|
|
'/usr/include/' + multiarch_path_component)
|
2011-05-31 19:33:28 +04:00
|
|
|
finally:
|
|
|
|
os.unlink(tmpfile)
|
2011-05-31 19:24:38 +04:00
|
|
|
|
2014-06-27 19:57:49 +04:00
|
|
|
|
2015-01-21 02:00:58 +03:00
|
|
|
def debug_build():
|
|
|
|
return hasattr(sys, 'gettotalrefcount')
|
|
|
|
|
2016-03-15 14:16:22 +03:00
|
|
|
|
|
|
|
setup(name=NAME,
|
|
|
|
version=PILLOW_VERSION,
|
|
|
|
description='Python Imaging Library (Fork)',
|
|
|
|
long_description=_read('README.rst').decode('utf-8'),
|
|
|
|
author='Alex Clark (Fork Author)',
|
|
|
|
author_email='aclark@aclark.net',
|
|
|
|
url='http://python-pillow.org',
|
|
|
|
classifiers=[
|
|
|
|
"Development Status :: 6 - Mature",
|
|
|
|
"Topic :: Multimedia :: Graphics",
|
|
|
|
"Topic :: Multimedia :: Graphics :: Capture :: Digital Camera",
|
|
|
|
"Topic :: Multimedia :: Graphics :: Capture :: Screen Capture",
|
|
|
|
"Topic :: Multimedia :: Graphics :: Graphics Conversion",
|
|
|
|
"Topic :: Multimedia :: Graphics :: Viewers",
|
|
|
|
"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",
|
|
|
|
"Programming Language :: Python :: 3.4",
|
|
|
|
"Programming Language :: Python :: 3.5",
|
|
|
|
'Programming Language :: Python :: Implementation :: CPython',
|
|
|
|
'Programming Language :: Python :: Implementation :: PyPy',
|
|
|
|
],
|
|
|
|
cmdclass={"build_ext": pil_build_ext},
|
|
|
|
ext_modules=[Extension("PIL._imaging", ["_imaging.c"])],
|
|
|
|
include_package_data=True,
|
|
|
|
packages=find_packages(),
|
|
|
|
scripts=glob.glob("Scripts/*.py"),
|
|
|
|
test_suite='nose.collector',
|
|
|
|
keywords=["Imaging", ],
|
|
|
|
license='Standard PIL License',
|
|
|
|
zip_safe=not debug_build(), )
|
2014-06-24 10:34:05 +04:00
|
|
|
# End of file
|