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