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