From e09580e12c7b7ad0b9ddca0ac4129f0bfb1020a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Fri, 31 May 2013 00:08:04 +0200 Subject: [PATCH] Introduce --enable-x and fail if it is given and x is not available. --- setup.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/setup.py b/setup.py index a150cf480..e2783c039 100644 --- a/setup.py +++ b/setup.py @@ -96,7 +96,10 @@ class pil_build_ext(build_ext): class feature: zlib = jpeg = tiff = freetype = tcl = tk = lcms = webp = None + required = [] + def require(self, feat): + return feat in self.required def want(self, feat): return getattr(self, feat) is None @@ -110,18 +113,28 @@ class pil_build_ext(build_ext): user_options = build_ext.user_options + [ ('disable-%s' % x, None, 'Disable support for %s' % x) for x in feature + ] + [ + ('enable-%s' % x, None, 'Enable 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) + setattr(self, 'enable_%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) + if getattr(self, 'enable_%s' % x): + raise ValueError( + 'Conflicting options: --enable-%s and --disable-%s' + % (x, x)) + if getattr(self, 'enable_%s' % x): + self.feature.required.append(x) def build_extensions(self): @@ -325,6 +338,12 @@ class pil_build_ext(build_ext): if _find_library_file(self, "webp"): # in googles precompiled zip it is call "libwebp" feature.webp = "webp" + for f in feature: + if not getattr(feature, f) and feature.require(f): + raise ValueError( + '--enable-%s requested but %s not found, aborting.' + % (f, f)) + # # core library