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