]> jfr.im git - irc/quakenet/qwebirc.git/blame - bin/dependencies_b.py
Merge.
[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
c60795d6 21 i+=check_autobahn()\r
becfa850 22 i+=check_json()\r
a409b906
CP
23 i+=check_java()\r
24 i+=check_hg()\r
c60795d6 25\r
a409b906
CP
26 print "0 errors, %d warnings." % i\r
27 \r
28 if i == 0:\r
29 print "looks like you've got everything you need to run qwebirc!"\r
30 else:\r
31 print "you can run qwebirc despite these."\r
32\r
33 f = open(".checked", "w")\r
34 f.close()\r
35 \r
36def check_win32():\r
37 if not sys.platform.startswith("win"):\r
38 return\r
39 \r
40 try:\r
41 import win32con\r
42 except ImportError:\r
43 fail("qwebirc requires pywin32, see:", "http://sourceforge.net/project/showfiles.php?group_id=78018")\r
44 \r
45def check_java():\r
46 def java_warn(specific):\r
47 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
48 \r
49 try:\r
f99fa3ee 50 p = subprocess.Popen(["java", "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=os.name == "nt")\r
a409b906
CP
51 p.communicate()\r
52 if p.wait() != 0:\r
53 java_warn("something went wrong looking for java.")\r
54 return 1\r
79221dd0 55 except: # ugh\r
a409b906
CP
56 java_warn("couldn't find java.")\r
57 return 1\r
58 \r
59 return 0\r
60 \r
61def check_hg():\r
62 def hg_warn(specific):\r
63 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
64 \r
65 try:\r
f99fa3ee 66 p = subprocess.Popen(["hg", "id"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=os.name == "nt")\r
a409b906
CP
67 p.communicate()\r
68 if p.wait() != 0:\r
69 hg_warn("something went wrong looking for mercurial.")\r
70 return 1\r
79221dd0 71 except: # ugh\r
a409b906
CP
72 hg_warn("couldn't find mercurial.")\r
73 return 1\r
74 \r
75 return 0\r
76 \r
3d0a1458
CP
77def check_zope():\r
78 try:\r
79 from zope.interface import Interface\r
80 except ImportError:\r
81 if sys.platform.startswith("win"):\r
82 fail("qwebirc requires zope interface",\r
83 "see pypi: http://pypi.python.org/pypi/zope.interface")\r
84 else:\r
85 fail("qwebirc requires zope interface.",\r
86 "this should normally come with twisted, but can be downloaded",\r
87 "from pypi: http://pypi.python.org/pypi/zope.interface")\r
c60795d6 88\r
a409b906
CP
89def check_twisted():\r
90 try:\r
91 import twisted\r
92 except ImportError:\r
93 fail("qwebirc requires twisted (at least 8.2.0), see http://twistedmatrix.com/")\r
94\r
0d221e0f
CP
95 def twisted_fail(x, y=None):\r
96 fail("you don't seem to have twisted's %s module." % x,\r
97 "your distro is most likely modular, look for a twisted %s package%s." % (x, " %s" % y if y else "",))\r
a409b906
CP
98\r
99 try:\r
100 import twisted.names\r
101 except ImportError:\r
102 twisted_fail("names")\r
103\r
104 try:\r
105 import twisted.mail\r
106 except ImportError:\r
107 twisted_fail("mail")\r
a409b906
CP
108\r
109 try:\r
110 import twisted.web\r
111 except ImportError:\r
112 twisted_fail("web", "(not web2)")\r
113\r
114 try:\r
115 import twisted.words\r
116 except ImportError:\r
0d221e0f 117 twisted_fail("words")\r
becfa850
CP
118 \r
119def check_json():\r
120 import qwebirc.util.qjson\r
121 if qwebirc.util.qjson.slow:\r
122 warn("simplejson module with C speedups not installed.",\r
123 "using embedded module (slower); consider installing simplejson from:",\r
124 "http://pypi.python.org/pypi/simplejson/")\r
125 return 1\r
126 return 0\r
c60795d6
CP
127\r
128def check_autobahn():\r
129 try:\r
033bd14a 130 import autobahn, autobahn.twisted.websocket\r
5a0fb86d
CP
131 x = autobahn.version.split(".")\r
132 if len(x) != 3:\r
033bd14a 133 raise ImportError()\r
5a0fb86d
CP
134 if (int(x[1]) < 8) or (int(x[1]) == 8 and int(x[2]) < 14):\r
135 raise ImportError()\r
c60795d6 136 return 0\r
7d179b4e 137 except ImportError:\r
5a0fb86d 138 warn("autobahn 0.8.14 (minimum) not installed; websocket support will be disabled.",\r
7d179b4e
CP
139 "consider installing autobahn from:",\r
140 "http://autobahn.ws/python/getstarted/")\r
141 return 1\r
c60795d6 142\r
a409b906
CP
143if __name__ == "__main__":\r
144 import dependencies\r
145 dependencies.check_dependencies()\r