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)
| 251 | RE_VERSION = re.compile(br'(\d+\.\d+(\.\d+)*)') |
| 252 | |
| 253 | def _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 | |
| 274 | def get_versions(): |
| 275 | """ Try to find out the versions of gcc, ld and dllwrap. |
no test coverage detected
searching dependent graphs…