mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +03:00 
			
		
		
		
	raise custom exceptions when required/requested items are not found
This commit is contained in:
		
							parent
							
								
									76d156bef0
								
							
						
					
					
						commit
						015e8cc266
					
				
							
								
								
									
										36
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								setup.py
									
									
									
									
									
								
							| 
						 | 
					@ -40,6 +40,8 @@ _LIB_IMAGING = (
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DEBUG = False
 | 
					DEBUG = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class DependencyException(Exception): pass
 | 
				
			||||||
 | 
					class DefaultDependencyException(Exception): pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def _dbg(s, tp=None):
 | 
					def _dbg(s, tp=None):
 | 
				
			||||||
    if DEBUG:
 | 
					    if DEBUG:
 | 
				
			||||||
| 
						 | 
					@ -558,12 +560,8 @@ class pil_build_ext(build_ext):
 | 
				
			||||||
        for f in feature:
 | 
					        for f in feature:
 | 
				
			||||||
            if not getattr(feature, f) and feature.require(f):
 | 
					            if not getattr(feature, f) and feature.require(f):
 | 
				
			||||||
                if f in ('jpeg', 'zlib'):
 | 
					                if f in ('jpeg', 'zlib'):
 | 
				
			||||||
                    raise ValueError(
 | 
					                    raise DefaultDependencyException(f)
 | 
				
			||||||
                        '%s is required unless explicitly disabled'
 | 
					                raise DependencyException(f)
 | 
				
			||||||
                        ' using --disable-%s, aborting' % (f, f))
 | 
					 | 
				
			||||||
                raise ValueError(
 | 
					 | 
				
			||||||
                    '--enable-%s requested but %s not found, aborting.' %
 | 
					 | 
				
			||||||
                    (f, f))
 | 
					 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
        #
 | 
					        #
 | 
				
			||||||
        # core library
 | 
					        # core library
 | 
				
			||||||
| 
						 | 
					@ -758,14 +756,14 @@ class pil_build_ext(build_ext):
 | 
				
			||||||
def debug_build():
 | 
					def debug_build():
 | 
				
			||||||
    return hasattr(sys, 'gettotalrefcount')
 | 
					    return hasattr(sys, 'gettotalrefcount')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					try:
 | 
				
			||||||
    setup(name=NAME,
 | 
					    setup(name=NAME,
 | 
				
			||||||
          version=PILLOW_VERSION,
 | 
					          version=PILLOW_VERSION,
 | 
				
			||||||
          description='Python Imaging Library (Fork)',
 | 
					          description='Python Imaging Library (Fork)',
 | 
				
			||||||
          long_description=_read('README.rst').decode('utf-8'),
 | 
					          long_description=_read('README.rst').decode('utf-8'),
 | 
				
			||||||
          author='Alex Clark (Fork Author)',
 | 
					          author='Alex Clark (Fork Author)',
 | 
				
			||||||
          author_email='aclark@aclark.net',
 | 
					          author_email='aclark@aclark.net',
 | 
				
			||||||
      url='https://python-pillow.org',
 | 
					          url='http://python-pillow.org',
 | 
				
			||||||
          classifiers=[
 | 
					          classifiers=[
 | 
				
			||||||
              "Development Status :: 6 - Mature",
 | 
					              "Development Status :: 6 - Mature",
 | 
				
			||||||
              "Topic :: Multimedia :: Graphics",
 | 
					              "Topic :: Multimedia :: Graphics",
 | 
				
			||||||
| 
						 | 
					@ -793,3 +791,25 @@ setup(name=NAME,
 | 
				
			||||||
          keywords=["Imaging", ],
 | 
					          keywords=["Imaging", ],
 | 
				
			||||||
          license='Standard PIL License',
 | 
					          license='Standard PIL License',
 | 
				
			||||||
          zip_safe=not debug_build(), )
 | 
					          zip_safe=not debug_build(), )
 | 
				
			||||||
 | 
					except DefaultDependencyException 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 DefaultDependencyException(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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user