3 import locale, os, subprocess, sys, traceback
5 added_zetuptoolz_egg = False
10 eggz = glob.glob('setuptools-*.egg')
12 egg = os.path.realpath(eggz[0])
13 print >>sys.stderr, "Inserting egg on sys.path: %r" % (egg,)
14 added_zetuptoolz_egg = True
15 sys.path.insert(0, egg)
18 return s.replace("\n", " ").replace("\r", "")
24 out = platform.platform()
25 print "platform:", foldlines(out)
26 print "machine: ", platform.machine()
27 if hasattr(platform, 'linux_distribution'):
28 print "linux_distribution:", repr(platform.linux_distribution())
29 except EnvironmentError:
30 sys.stderr.write("\nGot exception using 'platform'. Exception follows\n")
31 traceback.print_exc(file=sys.stderr)
35 def print_python_ver():
37 print "python:", foldlines(sys.version)
38 print 'maxunicode: ' + str(sys.maxunicode)
40 def print_python_encoding_settings():
42 print 'filesystem.encoding: ' + str(sys.getfilesystemencoding())
43 print 'locale.getpreferredencoding: ' + str(locale.getpreferredencoding())
45 print 'locale.defaultlocale: ' + str(locale.getdefaultlocale())
47 print 'got exception from locale.getdefaultlocale(): ', e
48 print 'locale.locale: ' + str(locale.getlocale())
50 def print_stdout(cmdlist, label=None):
53 res = subprocess.Popen(cmdlist, stdin=open(os.devnull),
54 stdout=subprocess.PIPE).communicate()[0]
57 print label + ': ' + foldlines(res)
58 except EnvironmentError:
59 sys.stderr.write("\nGot exception invoking '%s'. Exception follows.\n" % (cmdlist[0],))
60 traceback.print_exc(file=sys.stderr)
66 if os.path.exists('a.out'):
67 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'."
70 res = subprocess.Popen(['as', '-version'], stdin=open(os.devnull),
71 stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
72 print 'as: ' + foldlines(res[0]+' '+res[1])
73 if os.path.exists('a.out'):
75 except EnvironmentError:
76 sys.stderr.write("\nGot exception invoking '%s'. Exception follows.\n" % ('as',))
77 traceback.print_exc(file=sys.stderr)
81 def print_setuptools_ver():
83 if added_zetuptoolz_egg:
84 # it would be misleading to report the bundled version of zetuptoolz as the installed version
85 print "setuptools: using bundled egg"
89 out = str(pkg_resources.require("setuptools"))
90 print "setuptools:", foldlines(out)
91 except (ImportError, EnvironmentError):
92 sys.stderr.write("\nGot exception using 'pkg_resources' to get the version of setuptools. Exception follows\n")
93 traceback.print_exc(file=sys.stderr)
97 def print_py_pkg_ver(pkgname, modulename=None):
98 if modulename is None:
104 out = str(pkg_resources.require(pkgname))
105 print pkgname + ': ' + foldlines(out)
106 except (ImportError, EnvironmentError):
107 sys.stderr.write("\nGot exception using 'pkg_resources' to get the version of %s. Exception follows.\n" % (pkgname,))
108 traceback.print_exc(file=sys.stderr)
111 except pkg_resources.DistributionNotFound:
112 sys.stderr.write("\npkg_resources reported no %s package installed. Exception follows.\n" % (pkgname,))
113 traceback.print_exc(file=sys.stderr)
117 __import__(modulename)
121 modobj = sys.modules.get(modulename)
122 print pkgname + ' module: ' + str(modobj)
124 print pkgname + ' __version__: ' + str(modobj.__version__)
125 except AttributeError:
132 print_stdout(['locale'])
133 print_python_encoding_settings()
135 print_stdout(['buildbot', '--version'])
137 print_stdout(['gcc', '--version'])
138 print_stdout(['g++', '--version'])
139 print_stdout(['cryptest', 'V'])
140 print_stdout(['darcs', '--version'])
141 print_stdout(['darcs', '--exact-version'], label='darcs-exact-version')
142 print_stdout(['7za'])
143 print_stdout(['flappclient', '--version'])
144 print_stdout(['valgrind', '--version'])
148 print_setuptools_ver()
150 print_py_pkg_ver('coverage')
151 print_py_pkg_ver('trialcoverage')
152 print_py_pkg_ver('setuptools_trial')
153 print_py_pkg_ver('pyflakes')
154 print_py_pkg_ver('zope.interface')
155 print_py_pkg_ver('setuptools_darcs')
156 print_py_pkg_ver('darcsver')
157 print_py_pkg_ver('Twisted', 'twisted')
158 print_py_pkg_ver('TwistedCore', 'twisted.python')
159 print_py_pkg_ver('TwistedWeb', 'twisted.web')
160 print_py_pkg_ver('TwistedConch', 'twisted.conch')
161 print_py_pkg_ver('pycryptopp')