2009-02-19 08:35:58 +00:00
|
|
|
#! /usr/bin/env python
|
|
|
|
|
2012-04-01 00:59:25 +00:00
|
|
|
import locale, os, platform, subprocess, sys, traceback
|
2023-11-17 15:46:41 +00:00
|
|
|
from importlib.metadata import version, PackageNotFoundError
|
2010-05-04 04:56:43 +00:00
|
|
|
|
2010-11-06 22:44:04 +00:00
|
|
|
|
2011-11-01 07:45:32 +00:00
|
|
|
def foldlines(s, numlines=None):
|
|
|
|
lines = s.split("\n")
|
|
|
|
if numlines is not None:
|
|
|
|
lines = lines[:numlines]
|
|
|
|
return " ".join(lines).replace("\r", "")
|
2010-08-03 10:11:28 +00:00
|
|
|
|
2019-03-21 16:44:07 +00:00
|
|
|
|
2010-05-16 05:01:22 +00:00
|
|
|
def print_platform():
|
|
|
|
try:
|
|
|
|
import platform
|
|
|
|
out = platform.platform()
|
2019-03-22 10:40:58 +00:00
|
|
|
print("platform:", foldlines(out))
|
|
|
|
print("machine: ", platform.machine())
|
2010-06-08 00:45:23 +00:00
|
|
|
if hasattr(platform, 'linux_distribution'):
|
2019-03-22 10:40:58 +00:00
|
|
|
print("linux_distribution:", repr(platform.linux_distribution()))
|
2010-09-19 01:15:54 +00:00
|
|
|
except EnvironmentError:
|
2010-09-20 22:54:15 +00:00
|
|
|
sys.stderr.write("\nGot exception using 'platform'. Exception follows\n")
|
2010-09-19 01:15:54 +00:00
|
|
|
traceback.print_exc(file=sys.stderr)
|
2010-09-20 22:54:15 +00:00
|
|
|
sys.stderr.flush()
|
2009-02-19 08:35:58 +00:00
|
|
|
|
2019-03-21 16:44:07 +00:00
|
|
|
|
2010-05-16 05:01:22 +00:00
|
|
|
def print_python_ver():
|
2019-03-22 10:40:58 +00:00
|
|
|
print("python:", foldlines(sys.version))
|
|
|
|
print('maxunicode: ' + str(sys.maxunicode))
|
2010-08-03 10:11:28 +00:00
|
|
|
|
2019-03-21 16:44:07 +00:00
|
|
|
|
2010-08-03 10:11:28 +00:00
|
|
|
def print_python_encoding_settings():
|
2019-03-22 10:40:58 +00:00
|
|
|
print('filesystem.encoding: ' + str(sys.getfilesystemencoding()))
|
|
|
|
print('locale.getpreferredencoding: ' + str(locale.getpreferredencoding()))
|
2010-10-15 05:44:40 +00:00
|
|
|
try:
|
2019-03-22 10:40:58 +00:00
|
|
|
print('locale.defaultlocale: ' + str(locale.getdefaultlocale()))
|
2019-03-21 16:44:07 +00:00
|
|
|
except ValueError as e:
|
2019-03-22 10:40:58 +00:00
|
|
|
print('got exception from locale.getdefaultlocale(): ', e)
|
|
|
|
print('locale.locale: ' + str(locale.getlocale()))
|
2010-06-09 04:07:14 +00:00
|
|
|
|
2011-11-01 07:45:32 +00:00
|
|
|
def print_stdout(cmdlist, label=None, numlines=None):
|
2010-06-09 04:07:14 +00:00
|
|
|
try:
|
2010-08-03 10:11:28 +00:00
|
|
|
if label is None:
|
|
|
|
label = cmdlist[0]
|
2011-11-01 07:45:32 +00:00
|
|
|
res = subprocess.Popen(cmdlist, stdin=open(os.devnull),
|
|
|
|
stdout=subprocess.PIPE).communicate()[0]
|
2019-03-21 16:44:07 +00:00
|
|
|
print(label + ': ' + foldlines(res.decode('utf-8'), numlines))
|
|
|
|
except EnvironmentError as e:
|
2011-11-01 07:45:32 +00:00
|
|
|
if isinstance(e, OSError) and e.errno == 2:
|
2019-03-22 10:40:58 +00:00
|
|
|
print(label + ': no such file or directory')
|
2011-11-01 07:45:32 +00:00
|
|
|
return
|
2010-09-20 22:54:15 +00:00
|
|
|
sys.stderr.write("\nGot exception invoking '%s'. Exception follows.\n" % (cmdlist[0],))
|
2010-09-19 01:15:54 +00:00
|
|
|
traceback.print_exc(file=sys.stderr)
|
2010-09-20 22:54:15 +00:00
|
|
|
sys.stderr.flush()
|
2010-06-09 04:07:14 +00:00
|
|
|
|
2019-03-21 16:44:07 +00:00
|
|
|
|
2010-05-16 05:01:22 +00:00
|
|
|
def print_as_ver():
|
|
|
|
if os.path.exists('a.out'):
|
2019-03-21 16:44:07 +00:00
|
|
|
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'.")
|
2010-05-16 05:01:22 +00:00
|
|
|
return
|
|
|
|
try:
|
2019-03-21 16:44:07 +00:00
|
|
|
stdout, stderr = subprocess.Popen(['as', '-version'], stdin=open(os.devnull),
|
2010-08-03 10:11:28 +00:00
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
|
2019-03-21 16:44:07 +00:00
|
|
|
print('as: ' + foldlines(stdout.decode('utf-8') + ' ' + stderr.decode('utf-8')))
|
2010-08-03 09:48:12 +00:00
|
|
|
if os.path.exists('a.out'):
|
|
|
|
os.remove('a.out')
|
2010-09-19 01:15:54 +00:00
|
|
|
except EnvironmentError:
|
2010-09-20 22:54:15 +00:00
|
|
|
sys.stderr.write("\nGot exception invoking '%s'. Exception follows.\n" % ('as',))
|
2010-09-19 01:15:54 +00:00
|
|
|
traceback.print_exc(file=sys.stderr)
|
2010-09-20 22:54:15 +00:00
|
|
|
sys.stderr.flush()
|
2009-02-19 08:35:58 +00:00
|
|
|
|
2010-05-16 05:01:22 +00:00
|
|
|
def print_setuptools_ver():
|
|
|
|
try:
|
2023-11-17 15:46:41 +00:00
|
|
|
print("setuptools:", version("setuptools"))
|
|
|
|
except PackageNotFoundError:
|
2019-03-22 10:40:58 +00:00
|
|
|
print('setuptools: DistributionNotFound')
|
2009-06-21 05:58:46 +00:00
|
|
|
|
2019-03-21 16:44:07 +00:00
|
|
|
|
2010-10-30 07:02:33 +00:00
|
|
|
def print_py_pkg_ver(pkgname, modulename=None):
|
|
|
|
if modulename is None:
|
|
|
|
modulename = pkgname
|
2019-03-22 10:40:58 +00:00
|
|
|
print()
|
2010-05-16 05:01:22 +00:00
|
|
|
try:
|
2023-11-17 15:46:41 +00:00
|
|
|
print(pkgname + ': ' + version(pkgname))
|
|
|
|
except PackageNotFoundError:
|
2019-03-22 10:40:58 +00:00
|
|
|
print(pkgname + ': DistributionNotFound')
|
2010-10-30 07:02:33 +00:00
|
|
|
try:
|
|
|
|
__import__(modulename)
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
modobj = sys.modules.get(modulename)
|
2019-03-22 10:40:58 +00:00
|
|
|
print(pkgname + ' module: ' + str(modobj))
|
2010-10-30 07:02:33 +00:00
|
|
|
try:
|
2019-03-22 10:40:58 +00:00
|
|
|
print(pkgname + ' __version__: ' + str(modobj.__version__))
|
2010-10-30 07:02:33 +00:00
|
|
|
except AttributeError:
|
|
|
|
pass
|
2009-06-21 05:58:46 +00:00
|
|
|
|
2019-03-21 16:44:07 +00:00
|
|
|
|
2010-05-16 05:01:22 +00:00
|
|
|
print_platform()
|
2019-03-22 10:40:58 +00:00
|
|
|
print()
|
2010-05-16 05:01:22 +00:00
|
|
|
print_python_ver()
|
2016-02-22 20:41:35 +00:00
|
|
|
print_stdout(['virtualenv', '--version'])
|
2016-03-08 17:33:01 +00:00
|
|
|
print_stdout(['tox', '--version'])
|
2019-03-22 10:40:58 +00:00
|
|
|
print()
|
2010-08-03 10:11:28 +00:00
|
|
|
print_stdout(['locale'])
|
2010-06-09 04:07:14 +00:00
|
|
|
print_python_encoding_settings()
|
2019-03-22 10:40:58 +00:00
|
|
|
print()
|
2010-08-03 10:11:28 +00:00
|
|
|
print_stdout(['buildbot', '--version'])
|
2012-04-01 00:59:25 +00:00
|
|
|
print_stdout(['buildslave', '--version'])
|
|
|
|
if 'windows' in platform.system().lower():
|
2012-04-01 02:28:26 +00:00
|
|
|
print_stdout(['cl'])
|
2011-11-01 07:45:32 +00:00
|
|
|
print_stdout(['gcc', '--version'], numlines=1)
|
|
|
|
print_stdout(['g++', '--version'], numlines=1)
|
2010-08-03 10:11:28 +00:00
|
|
|
print_stdout(['cryptest', 'V'])
|
2012-04-01 00:59:25 +00:00
|
|
|
print_stdout(['git', '--version'])
|
|
|
|
print_stdout(['openssl', 'version'])
|
2010-09-23 07:23:25 +00:00
|
|
|
print_stdout(['flappclient', '--version'])
|
2010-11-18 03:06:23 +00:00
|
|
|
print_stdout(['valgrind', '--version'])
|
2010-05-10 06:29:55 +00:00
|
|
|
|
2010-05-16 05:01:22 +00:00
|
|
|
print_as_ver()
|
2010-05-10 06:29:55 +00:00
|
|
|
|
2010-05-16 05:01:22 +00:00
|
|
|
print_setuptools_ver()
|
2010-05-10 06:29:55 +00:00
|
|
|
|
2014-05-12 21:51:03 +00:00
|
|
|
print_py_pkg_ver('cffi')
|
2010-05-16 05:01:22 +00:00
|
|
|
print_py_pkg_ver('coverage')
|
2014-05-12 21:51:03 +00:00
|
|
|
print_py_pkg_ver('cryptography')
|
|
|
|
print_py_pkg_ver('foolscap')
|
|
|
|
print_py_pkg_ver('mock')
|
|
|
|
print_py_pkg_ver('pyasn1')
|
|
|
|
print_py_pkg_ver('pycparser')
|
2019-05-24 12:42:49 +00:00
|
|
|
print_py_pkg_ver('cryptography')
|
2010-06-07 05:16:18 +00:00
|
|
|
print_py_pkg_ver('pyflakes')
|
2014-05-12 21:51:03 +00:00
|
|
|
print_py_pkg_ver('pyOpenSSL', 'OpenSSL')
|
|
|
|
print_py_pkg_ver('six')
|
|
|
|
print_py_pkg_ver('trialcoverage')
|
2010-10-30 07:02:33 +00:00
|
|
|
print_py_pkg_ver('Twisted', 'twisted')
|
|
|
|
print_py_pkg_ver('TwistedCore', 'twisted.python')
|
|
|
|
print_py_pkg_ver('TwistedWeb', 'twisted.web')
|
|
|
|
print_py_pkg_ver('TwistedConch', 'twisted.conch')
|
2014-05-12 21:51:03 +00:00
|
|
|
print_py_pkg_ver('zfec')
|
|
|
|
print_py_pkg_ver('zope.interface')
|