]> jfr.im git - irc/quakenet/qwebirc.git/blob - bin/dependencies_b.py
tidy up autobahn support -- now requires 0.17.2
[irc/quakenet/qwebirc.git] / bin / dependencies_b.py
1 # this is separate to allow us to use python 2.5 syntax without
2 # the dependency checker breaking on earlier versions.
3
4 import sys
5 import subprocess
6 import os
7
8 def fail(*message):
9 print >>sys.stderr, "\n".join(message)
10 sys.exit(1)
11
12 def warn(*message):
13 print >>sys.stderr, "warning:", "\nwarning: ".join(message), "\n"
14
15 def check_dependencies():
16 i = 0
17
18 check_zope()
19 check_twisted()
20 check_win32()
21 i+=check_autobahn()
22 i+=check_json()
23 i+=check_java()
24 i+=check_git()
25
26 print "0 errors, %d warnings." % i
27
28 if i == 0:
29 print "looks like you've got everything you need to run qwebirc!"
30 else:
31 print "you can run qwebirc despite these."
32
33 f = open(".checked", "w")
34 f.close()
35
36 def check_win32():
37 if not sys.platform.startswith("win"):
38 return
39
40 try:
41 import win32con
42 except ImportError:
43 fail("qwebirc requires pywin32, see:", "http://sourceforge.net/project/showfiles.php?group_id=78018")
44
45 def check_java():
46 def java_warn(specific):
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/")
48
49 try:
50 p = subprocess.Popen(["java", "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=os.name == "nt")
51 p.communicate()
52 if p.wait() != 0:
53 java_warn("something went wrong looking for java.")
54 return 1
55 except: # ugh
56 java_warn("couldn't find java.")
57 return 1
58
59 return 0
60
61 def check_git():
62 def git_warn(specific):
63 warn(specific, "git is not required, but allows qwebirc to save bandwidth by versioning.")
64
65 try:
66 p = subprocess.Popen(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=os.name == "nt")
67 p.communicate()
68 if p.wait() != 0:
69 git_warn("something went wrong looking for git.")
70 return 1
71 except: # ugh
72 git_warn("couldn't find git.")
73 return 1
74
75 return 0
76
77 def check_zope():
78 try:
79 from zope.interface import Interface
80 except ImportError:
81 if sys.platform.startswith("win"):
82 fail("qwebirc requires zope interface",
83 "see pypi: http://pypi.python.org/pypi/zope.interface")
84 else:
85 fail("qwebirc requires zope interface.",
86 "this should normally come with twisted, but can be downloaded",
87 "from pypi: http://pypi.python.org/pypi/zope.interface")
88
89 def check_twisted():
90 try:
91 import twisted
92 except ImportError:
93 fail("qwebirc requires twisted (at least 8.2.0), see http://twistedmatrix.com/")
94
95 def twisted_fail(x, y=None):
96 fail("you don't seem to have twisted's %s module." % x,
97 "your distro is most likely modular, look for a twisted %s package%s." % (x, " %s" % y if y else "",))
98
99 try:
100 import twisted.names
101 except ImportError:
102 twisted_fail("names")
103
104 try:
105 import twisted.mail
106 except ImportError:
107 twisted_fail("mail")
108
109 try:
110 import twisted.web
111 except ImportError:
112 twisted_fail("web", "(not web2)")
113
114 try:
115 import twisted.words
116 except ImportError:
117 twisted_fail("words")
118
119 def check_json():
120 import qwebirc.util.qjson
121 if qwebirc.util.qjson.slow:
122 warn("simplejson module with C speedups not installed.",
123 "using embedded module (slower); consider installing simplejson from:",
124 "http://pypi.python.org/pypi/simplejson/")
125 return 1
126 return 0
127
128 def check_autobahn():
129 import qwebirc.util.autobahn_check as autobahn_check
130 v = autobahn_check.check()
131 if v == True:
132 return 0
133
134 if v == False:
135 warn("autobahn not installed; websocket support will be disabled.",
136 "consider installing autobahn from:",
137 "http://autobahn.ws/python/getstarted/")
138 return 1
139
140 warn("error loading autobahn: %s; websocket support will be disabled." % v,
141 "consider installing/upgrading autobahn from:",
142 "http://autobahn.ws/python/getstarted/")
143 return 1
144
145 if __name__ == "__main__":
146 import dependencies
147 dependencies.check_dependencies()