summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-05-31 22:33:03 (GMT)
committerGitHub <noreply@github.com>2018-05-31 22:33:03 (GMT)
commit56013218864d5eb81baab4665fcae13400934078 (patch)
tree58b89d60ccc2d425d79f90cac31db68a3fc6744f /Lib
parent110bc01407ac8c75545d0386577c6e17254d97d9 (diff)
downloadcpython-56013218864d5eb81baab4665fcae13400934078.zip
cpython-56013218864d5eb81baab4665fcae13400934078.tar.gz
cpython-56013218864d5eb81baab4665fcae13400934078.tar.bz2
bpo-33717: pythoninfo: add CC --version (#7290)
Get the version of the C compiler.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/pythoninfo.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py
index f1b0233..776f03f 100644
--- a/Lib/test/pythoninfo.py
+++ b/Lib/test/pythoninfo.py
@@ -489,6 +489,34 @@ def collect_test_support(info_add):
call_func(info_add, 'test_support.python_is_optimized', support, 'python_is_optimized')
+def collect_cc(info_add):
+ import subprocess
+ import sysconfig
+
+ CC = sysconfig.get_config_var('CC')
+ if not CC:
+ return
+
+ try:
+ import shlex
+ args = shlex.split(CC)
+ except ImportError:
+ args = CC.split()
+ args.append('--version')
+ proc = subprocess.Popen(args,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ universal_newlines=True)
+ stdout = proc.communicate()[0]
+ if proc.returncode:
+ # CC --version failed: ignore error
+ return
+
+ text = stdout.splitlines()[0]
+ text = normalize_text(text)
+ info_add('CC.version', text)
+
+
def collect_info(info):
error = False
info_add = info.add
@@ -515,6 +543,7 @@ def collect_info(info):
collect_decimal,
collect_testcapi,
collect_resource,
+ collect_cc,
# Collecting from tests should be last as they have side effects.
collect_test_socket,