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():
41 print_stderr([sys.executable, '-c', 'import sys; print >>sys.stderr, sys.stdout.encoding'], label='sys.stdout.encoding')
42 print_stdout([sys.executable, '-c', 'import sys; print sys.stderr.encoding'], label='sys.stderr.encoding')
44 print 'filesystem.encoding: ' + str(sys.getfilesystemencoding())
45 print 'locale.getpreferredencoding: ' + str(locale.getpreferredencoding())
46 print 'os.path.supports_unicode_filenames: ' + str(os.path.supports_unicode_filenames)
48 print 'locale.defaultlocale: ' + str(locale.getdefaultlocale())
50 print 'got exception from locale.getdefaultlocale(): ', e
51 print 'locale.locale: ' + str(locale.getlocale())
53 def print_stdout(cmdlist, label=None):
56 res = subprocess.Popen(cmdlist, stdin=open(os.devnull),
57 stdout=subprocess.PIPE).communicate()[0]
60 print label + ': ' + foldlines(res)
61 except EnvironmentError:
62 sys.stderr.write("\nGot exception invoking '%s'. Exception follows.\n" % (cmdlist[0],))
63 traceback.print_exc(file=sys.stderr)
67 def print_stderr(cmdlist, label=None):
70 res = subprocess.Popen(cmdlist, stdin=open(os.devnull),
71 stderr=subprocess.PIPE).communicate()[1]
74 print label + ': ' + foldlines(res)
75 except EnvironmentError:
76 sys.stderr.write("\nGot exception invoking '%s'. Exception follows\n" % (cmdlist[0],))
77 traceback.print_exc(file=sys.stderr)
83 if os.path.exists('a.out'):
84 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'."
87 res = subprocess.Popen(['as', '-version'], stdin=open(os.devnull),
88 stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
89 print 'as: ' + foldlines(res[0]+' '+res[1])
90 if os.path.exists('a.out'):
92 except EnvironmentError:
93 sys.stderr.write("\nGot exception invoking '%s'. Exception follows.\n" % ('as',))
94 traceback.print_exc(file=sys.stderr)
98 def print_setuptools_ver():
100 if added_zetuptoolz_egg:
101 # it would be misleading to report the bundled version of zetuptoolz as the installed version
102 print "setuptools: using bundled egg"
106 out = str(pkg_resources.require("setuptools"))
107 print "setuptools:", foldlines(out)
108 except (ImportError, EnvironmentError):
109 sys.stderr.write("\nGot exception using 'pkg_resources' to get the version of setuptools. Exception follows\n")
110 traceback.print_exc(file=sys.stderr)
114 def print_py_pkg_ver(pkgname, modulename=None):
115 if modulename is None:
121 out = str(pkg_resources.require(pkgname))
122 print pkgname + ': ' + foldlines(out)
123 except (ImportError, EnvironmentError):
124 sys.stderr.write("\nGot exception using 'pkg_resources' to get the version of %s. Exception follows.\n" % (pkgname,))
125 traceback.print_exc(file=sys.stderr)
128 except pkg_resources.DistributionNotFound:
129 sys.stderr.write("\npkg_resources reported no %s package installed. Exception follows.\n" % (pkgname,))
130 traceback.print_exc(file=sys.stderr)
134 __import__(modulename)
138 modobj = sys.modules.get(modulename)
139 print pkgname + ' module: ' + str(modobj)
141 print pkgname + ' __version__: ' + str(modobj.__version__)
142 except AttributeError:
149 print_stdout(['locale'])
150 print_python_encoding_settings()
152 print_stdout(['buildbot', '--version'])
154 print_stdout(['gcc', '--version'])
155 print_stdout(['g++', '--version'])
156 print_stdout(['cryptest', 'V'])
157 print_stdout(['darcs', '--version'])
158 print_stdout(['darcs', '--exact-version'], label='darcs-exact-version')
159 print_stdout(['7za'])
160 print_stdout(['flappclient', '--version'])
164 print_setuptools_ver()
166 print_py_pkg_ver('coverage')
167 print_py_pkg_ver('trialcoverage')
168 print_py_pkg_ver('setuptools_trial')
169 print_py_pkg_ver('pyflakes')
170 print_py_pkg_ver('zope.interface')
171 print_py_pkg_ver('setuptools_darcs')
172 print_py_pkg_ver('darcsver')
173 print_py_pkg_ver('Twisted', 'twisted')
174 print_py_pkg_ver('TwistedCore', 'twisted.python')
175 print_py_pkg_ver('TwistedWeb', 'twisted.web')
176 print_py_pkg_ver('TwistedConch', 'twisted.conch')