|
56 | 56 | CompileError, UnknownFileError)
|
57 | 57 | from distutils.version import LooseVersion
|
58 | 58 | from distutils.spawn import find_executable
|
| 59 | +from subprocess import Popen, PIPE, check_output |
59 | 60 |
|
60 | 61 | def get_msvcr():
|
61 | 62 | """Include the appropriate MSVC runtime library if Python was built
|
@@ -371,7 +372,7 @@ def check_config_h():
|
371 | 372 | return (CONFIG_H_UNCERTAIN,
|
372 | 373 | "couldn't read '%s': %s" % (fn, exc.strerror))
|
373 | 374 |
|
374 |
| -RE_VERSION = re.compile(br'(\d+\.\d+(\.\d+)*)') |
| 375 | +RE_VERSION = re.compile(br'[\D\s]*(\d+\.\d+(\.\d+)*)[\D\s]*') |
375 | 376 |
|
376 | 377 | def _find_exe_version(cmd):
|
377 | 378 | """Find the version of an executable by running `cmd` in the shell.
|
@@ -400,7 +401,16 @@ def get_versions():
|
400 | 401 |
|
401 | 402 | If not possible it returns None for it.
|
402 | 403 | """
|
403 |
| - commands = ['gcc -dumpversion', 'ld -v', 'dllwrap --version'] |
| 404 | + gcc = os.environ.get('CC') or 'gcc' |
| 405 | + ld = 'ld' |
| 406 | + out = Popen(gcc+' --print-prog-name ld', shell=True, stdout=PIPE).stdout |
| 407 | + try: |
| 408 | + ld = test=str(out.read(),encoding='utf-8').strip() |
| 409 | + finally: |
| 410 | + out.close() |
| 411 | + dllwrap = os.environ.get('DLLWRAP') or 'dllwrap' |
| 412 | + # MinGW64 doesn't have i686-w64-mingw32-ld, so instead we ask gcc. |
| 413 | + commands = [gcc+' -dumpversion', ld+' -v', dllwrap+' --version'] |
404 | 414 | return tuple([_find_exe_version(cmd) for cmd in commands])
|
405 | 415 |
|
406 | 416 | def is_cygwingcc():
|
|
0 commit comments