MCPcopy Create free account
hub / github.com/numpy/numpy / CCompiler_get_version

Function CCompiler_get_version

numpy/distutils/ccompiler.py:609–674  ·  view source on GitHub ↗

Return compiler version, or None if compiler is not available. Parameters ---------- force : bool, optional If True, force a new determination of the version, even if the compiler already has a version attribute. Default is False. ok_status : list of int, option

(self, force=False, ok_status=[0])

Source from the content-addressed store, hash-verified

607 return matcher
608
609def CCompiler_get_version(self, force=False, ok_status=[0]):
610 """
611 Return compiler version, or None if compiler is not available.
612
613 Parameters
614 ----------
615 force : bool, optional
616 If True, force a new determination of the version, even if the
617 compiler already has a version attribute. Default is False.
618 ok_status : list of int, optional
619 The list of status values returned by the version look-up process
620 for which a version string is returned. If the status value is not
621 in `ok_status`, None is returned. Default is ``[0]``.
622
623 Returns
624 -------
625 version : str or None
626 Version string, in the format of `distutils.version.LooseVersion`.
627
628 """
629 if not force and hasattr(self, 'version'):
630 return self.version
631 self.find_executables()
632 try:
633 version_cmd = self.version_cmd
634 except AttributeError:
635 return None
636 if not version_cmd or not version_cmd[0]:
637 return None
638 try:
639 matcher = self.version_match
640 except AttributeError:
641 try:
642 pat = self.version_pattern
643 except AttributeError:
644 return None
645 def matcher(version_string):
646 m = re.match(pat, version_string)
647 if not m:
648 return None
649 version = m.group('version')
650 return version
651
652 try:
653 output = subprocess.check_output(version_cmd, stderr=subprocess.STDOUT)
654 except subprocess.CalledProcessError as exc:
655 output = exc.output
656 status = exc.returncode
657 except OSError:
658 # match the historical returns for a parent
659 # exception class caught by exec_command()
660 status = 127
661 output = b''
662 else:
663 # output isn't actually a filepath but we do this
664 # for now to match previous distutils behavior
665 output = filepath_from_subprocess_output(output)
666 status = 0

Callers

nothing calls this directly

Calls 4

matcherFunction · 0.85
find_executablesMethod · 0.45
check_outputMethod · 0.45

Tested by

no test coverage detected