3 import locale, os, platform, subprocess, sys, traceback
5 added_zetuptoolz_egg = False
8 pkg_resources # hush pyflakes
11 eggz = glob.glob('setuptools-*.egg')
13 egg = os.path.realpath(eggz[0])
14 print >>sys.stderr, "Inserting egg on sys.path: %r" % (egg,)
15 added_zetuptoolz_egg = True
16 sys.path.insert(0, egg)
18 def foldlines(s, numlines=None):
20 if numlines is not None:
21 lines = lines[:numlines]
22 return " ".join(lines).replace("\r", "")
27 out = platform.platform()
28 print "platform:", foldlines(out)
29 print "machine: ", platform.machine()
30 if hasattr(platform, 'linux_distribution'):
31 print "linux_distribution:", repr(platform.linux_distribution())
32 except EnvironmentError:
33 sys.stderr.write("\nGot exception using 'platform'. Exception follows\n")
34 traceback.print_exc(file=sys.stderr)
38 def print_python_ver():
39 print "python:", foldlines(sys.version)
40 print 'maxunicode: ' + str(sys.maxunicode)
42 def print_python_encoding_settings():
43 print 'filesystem.encoding: ' + str(sys.getfilesystemencoding())
44 print 'locale.getpreferredencoding: ' + str(locale.getpreferredencoding())
46 print 'locale.defaultlocale: ' + str(locale.getdefaultlocale())
48 print 'got exception from locale.getdefaultlocale(): ', e
49 print 'locale.locale: ' + str(locale.getlocale())
51 def print_stdout(cmdlist, label=None, numlines=None):
55 res = subprocess.Popen(cmdlist, stdin=open(os.devnull),
56 stdout=subprocess.PIPE).communicate()[0]
57 print label + ': ' + foldlines(res, numlines)
58 except EnvironmentError, e:
59 if isinstance(e, OSError) and e.errno == 2:
60 print label + ': no such file or directory'
62 sys.stderr.write("\nGot exception invoking '%s'. Exception follows.\n" % (cmdlist[0],))
63 traceback.print_exc(file=sys.stderr)
68 if os.path.exists('a.out'):
69 print "WARNING: a file named a.out exists, and getting the version of the 'as' assembler writes to that filename, so I'm not attempting to get the version of 'as'."
72 res = subprocess.Popen(['as', '-version'], stdin=open(os.devnull),
73 stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
74 print 'as: ' + foldlines(res[0]+' '+res[1])
75 if os.path.exists('a.out'):
77 except EnvironmentError:
78 sys.stderr.write("\nGot exception invoking '%s'. Exception follows.\n" % ('as',))
79 traceback.print_exc(file=sys.stderr)
83 def print_setuptools_ver():
84 if added_zetuptoolz_egg:
85 # it would be misleading to report the bundled version of zetuptoolz as the installed version
86 print "setuptools: using bundled egg"
90 out = str(pkg_resources.require("setuptools"))
91 print "setuptools:", foldlines(out)
92 except (ImportError, EnvironmentError):
93 sys.stderr.write("\nGot exception using 'pkg_resources' to get the version of setuptools. Exception follows\n")
94 traceback.print_exc(file=sys.stderr)
97 except pkg_resources.DistributionNotFound:
98 print 'setuptools: DistributionNotFound'
101 def print_py_pkg_ver(pkgname, modulename=None):
102 if modulename is None:
107 out = str(pkg_resources.require(pkgname))
108 print pkgname + ': ' + foldlines(out)
109 except (ImportError, EnvironmentError):
110 sys.stderr.write("\nGot exception using 'pkg_resources' to get the version of %s. Exception follows.\n" % (pkgname,))
111 traceback.print_exc(file=sys.stderr)
114 except pkg_resources.DistributionNotFound:
115 print pkgname + ': DistributionNotFound'
118 __import__(modulename)
122 modobj = sys.modules.get(modulename)
123 print pkgname + ' module: ' + str(modobj)
125 print pkgname + ' __version__: ' + str(modobj.__version__)
126 except AttributeError:
133 print_stdout(['locale'])
134 print_python_encoding_settings()
136 print_stdout(['buildbot', '--version'])
137 print_stdout(['buildslave', '--version'])
138 if 'windows' in platform.system().lower():
140 print_stdout(['gcc', '--version'], numlines=1)
141 print_stdout(['g++', '--version'], numlines=1)
142 print_stdout(['cryptest', 'V'])
143 print_stdout(['git', '--version'])
144 print_stdout(['openssl', 'version'])
145 print_stdout(['flappclient', '--version'])
146 print_stdout(['valgrind', '--version'])
150 print_setuptools_ver()
152 print_py_pkg_ver('cffi')
153 print_py_pkg_ver('coverage')
154 print_py_pkg_ver('cryptography')
155 print_py_pkg_ver('foolscap')
156 print_py_pkg_ver('mock')
157 print_py_pkg_ver('Nevow', 'nevow')
158 print_py_pkg_ver('pyasn1')
159 print_py_pkg_ver('pycparser')
160 print_py_pkg_ver('pycrypto', 'Crypto')
161 print_py_pkg_ver('pycryptopp')
162 print_py_pkg_ver('pyflakes')
163 print_py_pkg_ver('pyOpenSSL', 'OpenSSL')
164 print_py_pkg_ver('simplejson')
165 print_py_pkg_ver('six')
166 print_py_pkg_ver('trialcoverage')
167 print_py_pkg_ver('Twisted', 'twisted')
168 print_py_pkg_ver('TwistedCore', 'twisted.python')
169 print_py_pkg_ver('TwistedWeb', 'twisted.web')
170 print_py_pkg_ver('TwistedConch', 'twisted.conch')
171 print_py_pkg_ver('zfec')
172 print_py_pkg_ver('zope.interface')