Skip to content

Commit 0f64262

Browse files
authored
bpo-33692: Update pythoninfo from master (GH-7304)
* bpo-33717: pythoninfo: add CC --version (GH-7290)
1 parent 8b98d2a commit 0f64262

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Lib/test/pythoninfo.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,34 @@ def collect_test_support(info_add):
497497
call_func(info_add, 'test_support.python_is_optimized', support, 'python_is_optimized')
498498

499499

500+
def collect_cc(info_add):
501+
import subprocess
502+
import sysconfig
503+
504+
CC = sysconfig.get_config_var('CC')
505+
if not CC:
506+
return
507+
508+
try:
509+
import shlex
510+
args = shlex.split(CC)
511+
except ImportError:
512+
args = CC.split()
513+
args.append('--version')
514+
proc = subprocess.Popen(args,
515+
stdout=subprocess.PIPE,
516+
stderr=subprocess.STDOUT,
517+
universal_newlines=True)
518+
stdout = proc.communicate()[0]
519+
if proc.returncode:
520+
# CC --version failed: ignore error
521+
return
522+
523+
text = stdout.splitlines()[0]
524+
text = normalize_text(text)
525+
info_add('CC.version', text)
526+
527+
500528
def collect_info(info):
501529
error = False
502530
info_add = info.add
@@ -523,6 +551,7 @@ def collect_info(info):
523551
collect_decimal,
524552
collect_testcapi,
525553
collect_resource,
554+
collect_cc,
526555

527556
# Collecting from tests should be last as they have side effects.
528557
collect_test_socket,

0 commit comments

Comments
 (0)