]>
Commit | Line | Data |
---|---|---|
61e6acc7 CP |
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() | |
ab2c1ee9 CP |
24 | i+=check_git() |
25 | ||
61e6acc7 CP |
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 | ||
ab2c1ee9 CP |
61 | def check_git(): |
62 | def git_warn(specific): | |
63 | warn(specific, "git is not required, but allows qwebirc to save bandwidth by versioning.") | |
61e6acc7 CP |
64 | |
65 | try: | |
ab2c1ee9 | 66 | p = subprocess.Popen(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=os.name == "nt") |
61e6acc7 CP |
67 | p.communicate() |
68 | if p.wait() != 0: | |
ab2c1ee9 | 69 | git_warn("something went wrong looking for git.") |
61e6acc7 CP |
70 | return 1 |
71 | except: # ugh | |
ab2c1ee9 | 72 | git_warn("couldn't find git.") |
61e6acc7 CP |
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 | try: | |
130 | import autobahn, autobahn.twisted.websocket | |
131 | x = autobahn.version.split(".") | |
132 | if len(x) != 3: | |
133 | raise ImportError() | |
134 | if (int(x[1]) < 8) or (int(x[1]) == 8 and int(x[2]) < 14): | |
135 | raise ImportError() | |
136 | return 0 | |
137 | except ImportError: | |
138 | warn("autobahn 0.8.14 (minimum) not installed; websocket support will be disabled.", | |
139 | "consider installing autobahn from:", | |
140 | "http://autobahn.ws/python/getstarted/") | |
141 | return 1 | |
142 | ||
143 | if __name__ == "__main__": | |
144 | import dependencies | |
145 | dependencies.check_dependencies() |