Source

sphinx / setup.py

Diff from to
 # -*- coding: utf-8 -*-
 import ez_setup
 ez_setup.use_setuptools()
+
+import sys
+from setuptools import setup, Feature
+
 import sphinx
 
-from setuptools import setup, Feature
-
 long_desc = '''
 Sphinx is a tool that makes it easy to create intelligent and beautiful
 documentation for Python projects (or other documents consisting of
   and inclusion of appropriately formatted docstrings.
 '''
 
+requires = ['Pygments>=0.8', 'docutils>=0.4']
+
+if sys.version_info < (2, 4):
+    print 'ERROR: Sphinx requires at least Python 2.4 to run.'
+    sys.exit(1)
+
+if sys.version_info < (2, 5):
+    # Python 2.4's distutils doesn't automatically install an egg-info,
+    # so an existing docutils install won't be detected -- in that case,
+    # remove the dependency from setup.py
+    try:
+        import docutils
+        if int(docutils.__version__[2]) < 4:
+            raise ValueError('docutils not recent enough')
+    except:
+        pass
+    else:
+        del requires[-1]
+
 setup(
     name='Sphinx',
     version=sphinx.__version__,
             'sphinx-quickstart = sphinx.quickstart:main'
         ]
     },
-    install_requires=['Pygments>=0.8', 'docutils>=0.4']
+    install_requires=requires,
 )