This repository has been archived by the owner on Oct 27, 2021. It is now read-only.
forked from python-pillow/Pillow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request python-pillow#2213 from wiredfool/setup
Raise custom exceptions when required/requested items are not found
- Loading branch information
Showing
1 changed file
with
61 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,8 @@ | |
|
||
DEBUG = False | ||
|
||
class DependencyException(Exception): pass | ||
class RequiredDependencyException(Exception): pass | ||
|
||
def _dbg(s, tp=None): | ||
if DEBUG: | ||
|
@@ -556,13 +558,9 @@ def build_extensions(self): | |
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,38 +754,60 @@ def add_multiarch_paths(self): | |
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='[email protected]', | ||
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(), ) | ||
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) | ||
|
||
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='[email protected]', | ||
url='https://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(), ) |