3 import locale, os, 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)
19 return s.replace("\n", " ").replace("\r", "")
25 out = platform.platform()
26 print "platform:", foldlines(out)
27 print "machine: ", platform.machine()
28 if hasattr(platform, 'linux_distribution'):
29 print "linux_distribution:", repr(platform.linux_distribution())
30 except EnvironmentError:
31 sys.stderr.write("\nGot exception using 'platform'. Exception follows\n")
32 traceback.print_exc(file=sys.stderr)
36 def print_python_ver():
38 print "python:", foldlines(sys.version)
39 print 'maxunicode: ' + str(sys.maxunicode)
41 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):
54 res = subprocess.Popen(cmdlist, stdin=open(os.devnull),
55 stdout=subprocess.PIPE).communicate()[0]
58 print label + ': ' + foldlines(res)
59 except EnvironmentError:
60 sys.stderr.write("\nGot exception invoking '%s'. Exception follows.\n" % (cmdlist[0],))
61 traceback.print_exc(file=sys.stderr)
67 if os.path.exists('a.out'):
68 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'."
71 res = subprocess.Popen(['as', '-version'], stdin=open(os.devnull),
72 stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
73 print 'as: ' + foldlines(res[0]+' '+res[1])
74 if os.path.exists('a.out'):
76 except EnvironmentError:
77 sys.stderr.write("\nGot exception invoking '%s'. Exception follows.\n" % ('as',))
78 traceback.print_exc(file=sys.stderr)
82 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)
98 def print_py_pkg_ver(pkgname, modulename=None):
99 if modulename is None:
105 out = str(pkg_resources.require(pkgname))
106 print pkgname + ': ' + foldlines(out)
107 except (ImportError, EnvironmentError):
108 sys.stderr.write("\nGot exception using 'pkg_resources' to get the version of %s. Exception follows.\n" % (pkgname,))
109 traceback.print_exc(file=sys.stderr)
112 except pkg_resources.DistributionNotFound:
113 sys.stderr.write("\npkg_resources reported no %s package installed. Exception follows.\n" % (pkgname,))
114 traceback.print_exc(file=sys.stderr)
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'])
138 print_stdout(['gcc', '--version'])
139 print_stdout(['g++', '--version'])
140 print_stdout(['cryptest', 'V'])
141 print_stdout(['darcs', '--version'])
142 print_stdout(['darcs', '--exact-version'], label='darcs-exact-version')
143 print_stdout(['7za'])
144 print_stdout(['flappclient', '--version'])
145 print_stdout(['valgrind', '--version'])
149 print_setuptools_ver()
151 print_py_pkg_ver('coverage')
152 print_py_pkg_ver('trialcoverage')
153 print_py_pkg_ver('setuptools_trial')
154 print_py_pkg_ver('pyflakes')
155 print_py_pkg_ver('zope.interface')
156 print_py_pkg_ver('setuptools_darcs')
157 print_py_pkg_ver('darcsver')
158 print_py_pkg_ver('Twisted', 'twisted')
159 print_py_pkg_ver('TwistedCore', 'twisted.python')
160 print_py_pkg_ver('TwistedWeb', 'twisted.web')
161 print_py_pkg_ver('TwistedConch', 'twisted.conch')
162 print_py_pkg_ver('pycryptopp')