changeset 7:230fb4ae30c7

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 eb0f4870a019
files setup.py
diffstat 1 files changed, 15 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Mon Dec 13 20:08:15 2010 -0800
+++ b/setup.py	Mon Mar 14 14:32:06 2011 -0700
@@ -1,5 +1,6 @@
 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')
@@ -7,7 +8,18 @@
 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,
@@ -22,13 +34,7 @@
       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]