Ticket #1286: twisted-requires-zi.patch.2.txt

File twisted-requires-zi.patch.2.txt, 1.4 KB (added by zooko, 7 years ago)

patch to make twisted's setup.py declare its dependency on zope.interface, but only if it is being evaluated by easy_install

Line 
1Index: twisted/__init__.py
2===================================================================
3--- twisted/__init__.py (revision 21763)
4+++ twisted/__init__.py (working copy)
5@@ -12,16 +12,18 @@
6 import sys
7 if not hasattr(sys, "version_info") or sys.version_info < (2,3):
8     raise RuntimeError("Twisted requires Python 2.3 or later.")
9+
10+if not 'setuptools' in sys.modules:
11+    # Ensure zope.interface is installed
12+    try:
13+        from zope.interface import Interface
14+        del Interface
15+    except ImportError:
16+        raise ImportError("you need zope.interface installed "
17+                          "(http://zope.org/Products/ZopeInterface/)")
18+
19 del sys
20 
21-# Ensure zope.interface is installed
22-try:
23-    from zope.interface import Interface
24-    del Interface
25-except ImportError:
26-    raise ImportError("you need zope.interface installed "
27-                      "(http://zope.org/Products/ZopeInterface/)")
28-
29 # Ensure compat gets imported
30 from twisted.python import compat
31 del compat
32Index: setup.py
33===================================================================
34--- setup.py    (revision 21763)
35+++ setup.py    (working copy)
36@@ -45,6 +45,8 @@
37         cmdclass={'build_ext': dist.build_ext_no_fail},
38         scripts=scripts,
39     )
40+    if 'setuptools' in sys.modules:
41+        setup_args['install_requires']=['zope.interface']
42     dist.setup(**setup_args)
43 
44