changeset 7:230fb4ae30c7 tip

look for PIL dynamically when running setup.py
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 14 Mar 2011 14:32:06 -0700
parents 0cd9a1362310
children
files setup.py
diffstat 1 files changed, 15 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py
+++ b/setup.py
@@ -1,37 +1,43 @@
 from setuptools import setup, find_packages
-import sys, os
+from pkg_resources import require, DistributionNotFound
+import os
 
 try:
     filename = os.path.join(os.path.dirname(__file__), 'README.txt')
     description = file(filename).read()
 except:
     description = ''
 
-version = '0.1.5'
+# Dependency check at run time
+# If PIL is not found, then it is added in the ``install_requires`` list
+install_requires = []   # Empty list if PIL is found
+try:
+    try:
+        require('PIL')
+    except DistributionNotFound:
+        require('Image')
+except DistributionNotFound:
+    install_requires = ['PIL']
+
+version = '0.1.6'
 
 setup(name='cropresize',
       version=version,
       description="crop and resize an image without doing the math yourself",
       long_description=description,
       classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
       keywords='image',
       author='Jeff Hammel',
       author_email='k0scist@gmail.com',
       url='http://pypi.python.org/pypi/cropresize',
       license='GPL',
       packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
       include_package_data=True,
       zip_safe=False,
-      install_requires=[
-          # -*- Extra requirements: -*-
-        'PIL',
-        ],
-      dependency_links=[
-        "http://dist.repoze.org/PIL-1.1.6.tar.gz",
-        ],
+      install_requires=install_requires,
       entry_points="""
       # -*- Entry points: -*-
       [console_scripts]
       crop-resize = cropresize:main
       """,
       )