mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-04-28 21:13:41 +03:00
Introduce --enable-x and fail if it is given and x is not available.
This commit is contained in:
parent
570c2adeaf
commit
e09580e12c
19
setup.py
19
setup.py
|
@ -96,7 +96,10 @@ class pil_build_ext(build_ext):
|
||||||
|
|
||||||
class feature:
|
class feature:
|
||||||
zlib = jpeg = tiff = freetype = tcl = tk = lcms = webp = None
|
zlib = jpeg = tiff = freetype = tcl = tk = lcms = webp = None
|
||||||
|
required = []
|
||||||
|
|
||||||
|
def require(self, feat):
|
||||||
|
return feat in self.required
|
||||||
def want(self, feat):
|
def want(self, feat):
|
||||||
return getattr(self, feat) is None
|
return getattr(self, feat) is None
|
||||||
|
|
||||||
|
@ -110,18 +113,28 @@ class pil_build_ext(build_ext):
|
||||||
user_options = build_ext.user_options + [
|
user_options = build_ext.user_options + [
|
||||||
('disable-%s' % x, None, 'Disable support for %s' % x)
|
('disable-%s' % x, None, 'Disable support for %s' % x)
|
||||||
for x in feature
|
for x in feature
|
||||||
|
] + [
|
||||||
|
('enable-%s' % x, None, 'Enable support for %s' % x)
|
||||||
|
for x in feature
|
||||||
]
|
]
|
||||||
|
|
||||||
def initialize_options(self):
|
def initialize_options(self):
|
||||||
build_ext.initialize_options(self)
|
build_ext.initialize_options(self)
|
||||||
for x in self.feature:
|
for x in self.feature:
|
||||||
setattr(self, 'disable_%s' % x, None)
|
setattr(self, 'disable_%s' % x, None)
|
||||||
|
setattr(self, 'enable_%s' % x, None)
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
build_ext.finalize_options(self)
|
build_ext.finalize_options(self)
|
||||||
for x in self.feature:
|
for x in self.feature:
|
||||||
if getattr(self, 'disable_%s' % x):
|
if getattr(self, 'disable_%s' % x):
|
||||||
setattr(self.feature, x, False)
|
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):
|
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"
|
if _find_library_file(self, "webp"): # in googles precompiled zip it is call "libwebp"
|
||||||
feature.webp = "webp"
|
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
|
# core library
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user