setup: new improved misc/show-tool-versions.py

This commit is contained in:
Zooko O'Whielacronx 2010-05-15 22:01:22 -07:00
parent 9179dd099a
commit e60b968be2

View File

@ -2,99 +2,86 @@
import os, subprocess, sys import os, subprocess, sys
try: def print_platform():
import platform try:
out = platform.platform() import platform
print out = platform.platform()
print "platform:", out.replace("\n", " ") print
except EnvironmentError, le: print "platform:", out.replace("\n", " ")
sys.stderr.write("Got exception using 'platform': %s" % (le,)) except EnvironmentError, le:
pass sys.stderr.write("Got exception using 'platform': %s\n" % (le,))
pass
print "python:", sys.version.replace("\n", " ") + ', maxunicode: ' + str(sys.maxunicode) def print_python_ver():
print "python:", sys.version.replace("\n", " ") + ', maxunicode: ' + str(sys.maxunicode)
try: def print_cmd_ver(cmdlist, label=None):
import pkg_resources try:
out = str(pkg_resources.require("setuptools")) res = subprocess.Popen(cmdlist, stdin=open(os.devnull),
print stdout=subprocess.PIPE).communicate()[0]
print "setuptools:", out.replace("\n", " ") if label is None:
except (ImportError, EnvironmentError), le: label = cmdlist[0]
sys.stderr.write("Got exception using 'pkg_resources' to get the version of setuptools: %s" % (le,)) print
pass print label + ': ' + res.replace("\n", " ")
except EnvironmentError, le:
sys.stderr.write("Got exception invoking '%s': %s\n" % (cmdlist[0], le,))
pass
try: def print_as_ver():
out = subprocess.Popen(["buildbot", "--version"], if os.path.exists('a.out'):
stdout=subprocess.PIPE).communicate()[0] print
print "buildbot:", out.replace("\n", " ") 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'."
except EnvironmentError, le: return
sys.stderr.write("Got exception invoking 'buildbot': %s" % (le,)) try:
pass res = subprocess.Popen(['as', '-version'], stdin=open(os.devnull),
stderr=subprocess.PIPE).communicate()[1]
print
print 'as: ' + res.replace("\n", " ")
os.remove('a.out')
except EnvironmentError, le:
sys.stderr.write("Got exception invoking '%s': %s\n" % ('as', le,))
pass
try: def print_setuptools_ver():
out = subprocess.Popen(["cl"], try:
stdout=subprocess.PIPE).communicate()[0] import pkg_resources
print "cl:", out.replace("\n", " ") out = str(pkg_resources.require("setuptools"))
except EnvironmentError, le: print
sys.stderr.write("Got exception invoking 'cl': %s" % (le,)) print "setuptools:", out.replace("\n", " ")
pass except (ImportError, EnvironmentError), le:
sys.stderr.write("Got exception using 'pkg_resources' to get the version of setuptools: %s\n" % (le,))
pass
try: def print_py_pkg_ver(pkgname):
out = subprocess.Popen(["g++", "--version"], try:
stdout=subprocess.PIPE).communicate()[0] import pkg_resources
print "g++:", out.replace("\n", " ") out = str(pkg_resources.require(pkgname))
except EnvironmentError, le: print
sys.stderr.write("Got exception invoking 'g++': %s" % (le,)) print pkgname + ': ' + out.replace("\n", " ")
pass except (ImportError, EnvironmentError), le:
sys.stderr.write("Got exception using 'pkg_resources' to get the version of %s: %s\n" % (pkgname, le,))
pass
except pkg_resources.DistributionNotFound, le:
sys.stderr.write("pkg_resources reported no %s package installed: %s\n" % (pkgname, le,))
pass
try: print_platform()
out = subprocess.Popen(["gcc", "--version"],
stdout=subprocess.PIPE).communicate()[0]
print "gcc:", out.replace("\n", " ")
except EnvironmentError, le:
sys.stderr.write("Got exception invoking 'gcc': %s" % (le,))
pass
try: print_python_ver()
out = subprocess.Popen(["as", "-version"], stdin=open(os.devnull),
stdout=subprocess.PIPE).communicate()[0]
print "as:", out.replace("\n", " ")
except EnvironmentError, le:
sys.stderr.write("Got exception invoking 'as': %s" % (le,))
pass
try: print_cmd_ver(['buildbot', '--version'])
out = subprocess.Popen(["darcs", "--version"], print_cmd_ver(['cl'])
stdout=subprocess.PIPE).communicate()[0] print_cmd_ver(['gcc', '--version'])
full = subprocess.Popen(["darcs", "--exact-version"], print_cmd_ver(['g++', '--version'])
stdout=subprocess.PIPE).communicate()[0] print_cmd_ver(['cryptest', 'V'])
print print_cmd_ver(['darcs', '--version'])
print "darcs:", out.replace("\n", " ") print_cmd_ver(['darcs', '--exact-version'], label='darcs-exact-version')
print full.rstrip() print_cmd_ver(['7za'])
except EnvironmentError, le:
sys.stderr.write("Got exception invoking 'darcs': %s" % (le,))
pass
try: print_as_ver()
import pkg_resources
out = str(pkg_resources.require("coverage"))
print
print "coverage:", out.replace("\n", " ")
except (ImportError, EnvironmentError), le:
sys.stderr.write("Got exception using 'pkg_resources' to get the version of coverage: %s" % (le,))
pass
except pkg_resources.DistributionNotFound, le:
sys.stderr.write("pkg_resources reported no trialcoverage package installed: %s" % (le,))
pass
try: print_setuptools_ver()
import pkg_resources
out = str(pkg_resources.require("trialcoverage"))
print
print "trialcoverage:", out.replace("\n", " ")
except (ImportError, EnvironmentError), le:
sys.stderr.write("Got exception using 'pkg_resources' to get the version of trialcoverage: %s" % (le,))
pass
except pkg_resources.DistributionNotFound, le:
sys.stderr.write("pkg_resources reported no trialcoverage package installed: %s" % (le,))
pass
print_py_pkg_ver('coverage')
print_py_pkg_ver('trialcoverage')
print_py_pkg_ver('setuptools_trial')