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

Function _find_exe_version

Tools/c-analyzer/distutils/cygwinccompiler.py:253–272  ·  view source on GitHub ↗

Find the version of an executable by running `cmd` in the shell. If the command is not found, or the output does not match `RE_VERSION`, returns None.

(cmd)

Source from the content-addressed store, hash-verified

251RE_VERSION = re.compile(br'(\d+\.\d+(\.\d+)*)')
252
253def _find_exe_version(cmd):
254 """Find the version of an executable by running `cmd` in the shell.
255
256 If the command is not found, or the output does not match
257 `RE_VERSION`, returns None.
258 """
259 executable = cmd.split()[0]
260 if find_executable(executable) is None:
261 return None
262 out = Popen(cmd, shell=True, stdout=PIPE).stdout
263 try:
264 out_string = out.read()
265 finally:
266 out.close()
267 result = RE_VERSION.search(out_string)
268 if result is None:
269 return None
270 # LooseVersion works with strings
271 # so we need to decode our bytes
272 return LooseVersion(result.group(1).decode())
273
274def get_versions():
275 """ Try to find out the versions of gcc, ld and dllwrap.

Callers 1

get_versionsFunction · 0.85

Calls 8

find_executableFunction · 0.90
PopenClass · 0.90
splitMethod · 0.45
readMethod · 0.45
closeMethod · 0.45
searchMethod · 0.45
decodeMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…