]> jfr.im git - irc/quakenet/qwebirc.git/blame - bin/dependencies_b.py
fix dependency ordering for zope interface (twisted now has its own dependency checke...
[irc/quakenet/qwebirc.git] / bin / dependencies_b.py
CommitLineData
15d26968 1# this is separate to allow us to use python 2.5 syntax without\r
a409b906
CP
2# the dependency checker breaking on earlier versions.\r
3\r
4import sys\r
5import subprocess\r
15d26968 6import os\r
a409b906
CP
7\r
8def fail(*message):\r
9 print >>sys.stderr, "\n".join(message)\r
10 sys.exit(1)\r
11 \r
12def warn(*message):\r
13 print >>sys.stderr, "warning:", "\nwarning: ".join(message), "\n"\r
14\r
15def check_dependencies():\r
16 i = 0\r
5e83905f 17\r
3d0a1458 18 check_zope()\r
5e83905f 19 check_twisted()\r
a409b906 20 check_win32()\r
becfa850 21 i+=check_json()\r
a409b906
CP
22 i+=check_java()\r
23 i+=check_hg()\r
24 \r
25 print "0 errors, %d warnings." % i\r
26 \r
27 if i == 0:\r
28 print "looks like you've got everything you need to run qwebirc!"\r
29 else:\r
30 print "you can run qwebirc despite these."\r
31\r
32 f = open(".checked", "w")\r
33 f.close()\r
34 \r
35def check_win32():\r
36 if not sys.platform.startswith("win"):\r
37 return\r
38 \r
39 try:\r
40 import win32con\r
41 except ImportError:\r
42 fail("qwebirc requires pywin32, see:", "http://sourceforge.net/project/showfiles.php?group_id=78018")\r
43 \r
44def check_java():\r
45 def java_warn(specific):\r
46 warn(specific, "java is not required, but allows qwebirc to compress output,", "making it faster to download.", "you can get java at http://www.java.com/")\r
47 \r
48 try:\r
f99fa3ee 49 p = subprocess.Popen(["java", "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=os.name == "nt")\r
a409b906
CP
50 p.communicate()\r
51 if p.wait() != 0:\r
52 java_warn("something went wrong looking for java.")\r
53 return 1\r
79221dd0 54 except: # ugh\r
a409b906
CP
55 java_warn("couldn't find java.")\r
56 return 1\r
57 \r
58 return 0\r
59 \r
60def check_hg():\r
61 def hg_warn(specific):\r
62 warn(specific, "mercurial (hg) is not required, but allows qwebirc to save bandwidth by versioning.", "you can get hg at http://www.selenic.com/mercurial/")\r
63 \r
64 try:\r
f99fa3ee 65 p = subprocess.Popen(["hg", "id"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=os.name == "nt")\r
a409b906
CP
66 p.communicate()\r
67 if p.wait() != 0:\r
68 hg_warn("something went wrong looking for mercurial.")\r
69 return 1\r
79221dd0 70 except: # ugh\r
a409b906
CP
71 hg_warn("couldn't find mercurial.")\r
72 return 1\r
73 \r
74 return 0\r
75 \r
3d0a1458
CP
76def check_zope():\r
77 try:\r
78 from zope.interface import Interface\r
79 except ImportError:\r
80 if sys.platform.startswith("win"):\r
81 fail("qwebirc requires zope interface",\r
82 "see pypi: http://pypi.python.org/pypi/zope.interface")\r
83 else:\r
84 fail("qwebirc requires zope interface.",\r
85 "this should normally come with twisted, but can be downloaded",\r
86 "from pypi: http://pypi.python.org/pypi/zope.interface")\r
87 \r
a409b906
CP
88def check_twisted():\r
89 try:\r
90 import twisted\r
91 except ImportError:\r
92 fail("qwebirc requires twisted (at least 8.2.0), see http://twistedmatrix.com/")\r
93\r
0d221e0f
CP
94 def twisted_fail(x, y=None):\r
95 fail("you don't seem to have twisted's %s module." % x,\r
96 "your distro is most likely modular, look for a twisted %s package%s." % (x, " %s" % y if y else "",))\r
a409b906
CP
97\r
98 try:\r
99 import twisted.names\r
100 except ImportError:\r
101 twisted_fail("names")\r
102\r
103 try:\r
104 import twisted.mail\r
105 except ImportError:\r
106 twisted_fail("mail")\r
a409b906
CP
107\r
108 try:\r
109 import twisted.web\r
110 except ImportError:\r
111 twisted_fail("web", "(not web2)")\r
112\r
113 try:\r
114 import twisted.words\r
115 except ImportError:\r
0d221e0f 116 twisted_fail("words")\r
becfa850
CP
117 \r
118def check_json():\r
119 import qwebirc.util.qjson\r
120 if qwebirc.util.qjson.slow:\r
121 warn("simplejson module with C speedups not installed.",\r
122 "using embedded module (slower); consider installing simplejson from:",\r
123 "http://pypi.python.org/pypi/simplejson/")\r
124 return 1\r
125 return 0\r
126 \r
a409b906
CP
127if __name__ == "__main__":\r
128 import dependencies\r
129 dependencies.check_dependencies()\r