MCPcopy Index your code
hub / github.com/python/cpython / display_header

Function display_header

Lib/test/libregrtest/utils.py:637–713  ·  view source on GitHub ↗
(use_resources: dict[str, str | None],
                   python_cmd: tuple[str, ...] | None)

Source from the content-addressed store, hash-verified

635
636
637def display_header(use_resources: dict[str, str | None],
638 python_cmd: tuple[str, ...] | None) -> None:
639 # Print basic platform information
640 print("==", platform.python_implementation(), *sys.version.split())
641 print("==", platform.platform(aliased=True),
642 "%s-endian" % sys.byteorder)
643 print("== Python build:", ' '.join(get_build_info()))
644 print("== cwd:", os.getcwd())
645
646 cpu_count: object = os.cpu_count()
647 if cpu_count:
648 # The function is new in Python 3.13; mypy doesn't know about it yet:
649 process_cpu_count = os.process_cpu_count() # type: ignore[attr-defined]
650 if process_cpu_count and process_cpu_count != cpu_count:
651 cpu_count = f"{process_cpu_count} (process) / {cpu_count} (system)"
652 print("== CPU count:", cpu_count)
653 print("== encodings: locale=%s FS=%s"
654 % (locale.getencoding(), sys.getfilesystemencoding()))
655
656 if use_resources:
657 text = format_resources(use_resources)
658 print(f"== {text}")
659 else:
660 print("== resources: all test resources are disabled, "
661 "use -u option to unskip tests")
662
663 cross_compile = is_cross_compiled()
664 if cross_compile:
665 print("== cross compiled: Yes")
666 if python_cmd:
667 cmd = shlex.join(python_cmd)
668 print(f"== host python: {cmd}")
669
670 get_cmd = [*python_cmd, '-m', 'platform']
671 proc = subprocess.run(
672 get_cmd,
673 stdout=subprocess.PIPE,
674 text=True,
675 cwd=os_helper.SAVEDCWD)
676 stdout = proc.stdout.replace('\n', ' ').strip()
677 if stdout:
678 print(f"== host platform: {stdout}")
679 elif proc.returncode:
680 print(f"== host platform: <command failed with exit code {proc.returncode}>")
681 else:
682 hostrunner = get_host_runner()
683 if hostrunner:
684 print(f"== host runner: {hostrunner}")
685
686 # This makes it easier to remember what to set in your local
687 # environment when trying to reproduce a sanitizer failure.
688 asan = support.check_sanitizer(address=True)
689 msan = support.check_sanitizer(memory=True)
690 ubsan = support.check_sanitizer(ub=True)
691 tsan = support.check_sanitizer(thread=True)
692 sanitizers = []
693 if asan:
694 sanitizers.append("address")

Callers 1

_run_testsMethod · 0.85

Calls 11

get_build_infoFunction · 0.85
format_resourcesFunction · 0.85
is_cross_compiledFunction · 0.85
get_host_runnerFunction · 0.85
cpu_countMethod · 0.80
joinMethod · 0.45
runMethod · 0.45
stripMethod · 0.45
replaceMethod · 0.45
appendMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…