compilers: detect cython version on stdout for newer cython versions

Cython historically, when asked to print the version and exit
successfully, would do so on stderr, which is weird and inconsistent.
Recently, it fixed this UX bug by printing on stdout instead:

https://github.com/cython/cython/issues/5504

This then broke meson detection because we assumed it was on stderr due
to historically being there:

https://github.com/scipy/scipy/issues/18865

Cython is right, and shouldn't have to revert this reasonable change for
backwards compatibility. Instead, check both.
pull/11975/head
Eli Schwartz 1 year ago
parent 2c1e2b680e
commit e2ce53b6b4
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 12
      mesonbuild/compilers/detect.py

@ -927,13 +927,19 @@ def detect_cython_compiler(env: 'Environment', for_machine: MachineChoice) -> Co
popen_exceptions: T.Dict[str, Exception] = {}
for comp in compilers:
try:
err = Popen_safe_logged(comp + ['-V'], msg='Detecting compiler via')[2]
_, out, err = Popen_safe_logged(comp + ['-V'], msg='Detecting compiler via')
except OSError as e:
popen_exceptions[join_args(comp + ['-V'])] = e
continue
version = search_version(err)
if 'Cython' in err:
version: T.Optional[str] = None
# 3.0
if 'Cython' in out:
version = search_version(out)
# older
elif 'Cython' in err:
version = search_version(err)
if version is not None:
comp_class = CythonCompiler
env.coredata.add_lang_args(comp_class.language, comp_class, for_machine, env)
return comp_class([], comp, version, for_machine, info, is_cross=is_cross)

Loading…
Cancel
Save