mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-05-05 00:13:42 +03:00
Support --disable-* switches to disable features.
For example, --disable-jpeg unconditionally disables both checks jpeg support and checks for libjpeg.
This commit is contained in:
parent
eeac3fedef
commit
810e916342
38
setup.py
38
setup.py
|
@ -94,6 +94,32 @@ LCMS_ROOT = None
|
||||||
|
|
||||||
class pil_build_ext(build_ext):
|
class pil_build_ext(build_ext):
|
||||||
|
|
||||||
|
class feature:
|
||||||
|
zlib = jpeg = tiff = freetype = tcl = tk = lcms = webp = None
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
for x in dir(self):
|
||||||
|
if x[1] != '_':
|
||||||
|
yield x
|
||||||
|
|
||||||
|
feature = feature()
|
||||||
|
|
||||||
|
user_options = build_ext.user_options + [
|
||||||
|
('disable-%s' % x, None, 'Disable support for %s' % x)
|
||||||
|
for x in feature
|
||||||
|
]
|
||||||
|
|
||||||
|
def initialize_options(self):
|
||||||
|
build_ext.initialize_options(self)
|
||||||
|
for x in self.feature:
|
||||||
|
setattr(self, 'disable_%s' % x, None)
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
build_ext.finalize_options(self)
|
||||||
|
for x in self.feature:
|
||||||
|
if getattr(self, 'disable_%s' % x):
|
||||||
|
setattr(self.feature, x, False)
|
||||||
|
|
||||||
def build_extensions(self):
|
def build_extensions(self):
|
||||||
|
|
||||||
global TCL_ROOT
|
global TCL_ROOT
|
||||||
|
@ -223,16 +249,16 @@ class pil_build_ext(build_ext):
|
||||||
#
|
#
|
||||||
# look for available libraries
|
# look for available libraries
|
||||||
|
|
||||||
class feature:
|
feature = self.feature
|
||||||
zlib = jpeg = tiff = freetype = tcl = tk = lcms = webp = None
|
|
||||||
feature = feature()
|
|
||||||
|
|
||||||
|
if feature.zlib is None:
|
||||||
if _find_include_file(self, "zlib.h"):
|
if _find_include_file(self, "zlib.h"):
|
||||||
if _find_library_file(self, "z"):
|
if _find_library_file(self, "z"):
|
||||||
feature.zlib = "z"
|
feature.zlib = "z"
|
||||||
elif sys.platform == "win32" and _find_library_file(self, "zlib"):
|
elif sys.platform == "win32" and _find_library_file(self, "zlib"):
|
||||||
feature.zlib = "zlib" # alternative name
|
feature.zlib = "zlib" # alternative name
|
||||||
|
|
||||||
|
if feature.jpeg is None:
|
||||||
if _find_include_file(self, "jpeglib.h"):
|
if _find_include_file(self, "jpeglib.h"):
|
||||||
if _find_library_file(self, "jpeg"):
|
if _find_library_file(self, "jpeg"):
|
||||||
feature.jpeg = "jpeg"
|
feature.jpeg = "jpeg"
|
||||||
|
@ -241,6 +267,7 @@ class pil_build_ext(build_ext):
|
||||||
_find_library_file(self, "libjpeg")):
|
_find_library_file(self, "libjpeg")):
|
||||||
feature.jpeg = "libjpeg" # alternative name
|
feature.jpeg = "libjpeg" # alternative name
|
||||||
|
|
||||||
|
if feature.tiff is None:
|
||||||
if _find_library_file(self, "tiff"):
|
if _find_library_file(self, "tiff"):
|
||||||
feature.tiff = "tiff"
|
feature.tiff = "tiff"
|
||||||
if sys.platform == "win32" and _find_library_file(self, "libtiff"):
|
if sys.platform == "win32" and _find_library_file(self, "libtiff"):
|
||||||
|
@ -248,6 +275,7 @@ class pil_build_ext(build_ext):
|
||||||
if sys.platform == "darwin" and _find_library_file(self, "libtiff"):
|
if sys.platform == "darwin" and _find_library_file(self, "libtiff"):
|
||||||
feature.tiff = "libtiff"
|
feature.tiff = "libtiff"
|
||||||
|
|
||||||
|
if feature.freetype is None:
|
||||||
if _find_library_file(self, "freetype"):
|
if _find_library_file(self, "freetype"):
|
||||||
# look for freetype2 include files
|
# look for freetype2 include files
|
||||||
freetype_version = 0
|
freetype_version = 0
|
||||||
|
@ -269,6 +297,7 @@ class pil_build_ext(build_ext):
|
||||||
if dir:
|
if dir:
|
||||||
_add_directory(self.compiler.include_dirs, dir, 0)
|
_add_directory(self.compiler.include_dirs, dir, 0)
|
||||||
|
|
||||||
|
if feature.lcms is None:
|
||||||
if _find_include_file(self, "lcms.h"):
|
if _find_include_file(self, "lcms.h"):
|
||||||
if _find_library_file(self, "lcms"):
|
if _find_library_file(self, "lcms"):
|
||||||
feature.lcms = "lcms"
|
feature.lcms = "lcms"
|
||||||
|
@ -276,15 +305,18 @@ class pil_build_ext(build_ext):
|
||||||
if _tkinter and _find_include_file(self, "tk.h"):
|
if _tkinter and _find_include_file(self, "tk.h"):
|
||||||
# the library names may vary somewhat (e.g. tcl84 or tcl8.4)
|
# the library names may vary somewhat (e.g. tcl84 or tcl8.4)
|
||||||
version = TCL_VERSION[0] + TCL_VERSION[2]
|
version = TCL_VERSION[0] + TCL_VERSION[2]
|
||||||
|
if feature.tcl is None:
|
||||||
if _find_library_file(self, "tcl" + version):
|
if _find_library_file(self, "tcl" + version):
|
||||||
feature.tcl = "tcl" + version
|
feature.tcl = "tcl" + version
|
||||||
elif _find_library_file(self, "tcl" + TCL_VERSION):
|
elif _find_library_file(self, "tcl" + TCL_VERSION):
|
||||||
feature.tcl = "tcl" + TCL_VERSION
|
feature.tcl = "tcl" + TCL_VERSION
|
||||||
|
if feature.tk is None:
|
||||||
if _find_library_file(self, "tk" + version):
|
if _find_library_file(self, "tk" + version):
|
||||||
feature.tk = "tk" + version
|
feature.tk = "tk" + version
|
||||||
elif _find_library_file(self, "tk" + TCL_VERSION):
|
elif _find_library_file(self, "tk" + TCL_VERSION):
|
||||||
feature.tk = "tk" + TCL_VERSION
|
feature.tk = "tk" + TCL_VERSION
|
||||||
|
|
||||||
|
if feature.webp is None:
|
||||||
if (_find_include_file(self, "webp/encode.h") and
|
if (_find_include_file(self, "webp/encode.h") and
|
||||||
_find_include_file(self, "webp/decode.h")):
|
_find_include_file(self, "webp/decode.h")):
|
||||||
if _find_library_file(self, "webp"): # in googles precompiled zip it is call "libwebp"
|
if _find_library_file(self, "webp"): # in googles precompiled zip it is call "libwebp"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user