Merge pull request #2213 from wiredfool/setup

Raise custom exceptions when required/requested items are not found
This commit is contained in:
wiredfool 2016-11-22 12:14:57 +00:00 committed by GitHub
commit 70c2df21ca

View File

@ -40,6 +40,8 @@ _LIB_IMAGING = (
DEBUG = False
class DependencyException(Exception): pass
class RequiredDependencyException(Exception): pass
def _dbg(s, tp=None):
if DEBUG:
@ -556,12 +558,8 @@ class pil_build_ext(build_ext):
for f in feature:
if not getattr(feature, f) and feature.require(f):
if f in ('jpeg', 'zlib'):
raise ValueError(
'%s is required unless explicitly disabled'
' using --disable-%s, aborting' % (f, f))
raise ValueError(
'--enable-%s requested but %s not found, aborting.' %
(f, f))
raise RequiredDependencyException(f)
raise DependencyException(f)
#
# core library
@ -756,14 +754,14 @@ class pil_build_ext(build_ext):
def debug_build():
return hasattr(sys, 'gettotalrefcount')
try:
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='https://python-pillow.org',
url='http://python-pillow.org',
classifiers=[
"Development Status :: 6 - Mature",
"Topic :: Multimedia :: Graphics",
@ -791,3 +789,25 @@ setup(name=NAME,
keywords=["Imaging", ],
license='Standard PIL License',
zip_safe=not debug_build(), )
except RequiredDependencyException as err:
msg = """
The headers or library files could not be found for %s,
a required dependency when compiling Pillow from source.
Please see the install instructions at:
http://pillow.readthedocs.io/en/latest/installation.html
""" % (str(err))
sys.stderr.write(msg)
raise RequiredDependencyException(msg)
except DependencyException as err:
msg = """
The headers or library files could not be found for %s,
which was requested by the option flag --enable-%s
""" % (str(err), str(err))
sys.stderr.write(msg)
raise DependencyException(msg)