-
-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Milestone
Description
Describe the issue:
Aesara uses numpy.distutils.system_info.get_info("blas_opt") to obtain some compiler settings upon import.
However, every this prints the GCC configuration to stdout which is incredibly annoying.
We tried to capture/suppress the stdout/stderr output (see below), but it doesn't work.
Related issues/PRs:
- NumPy compiler warnings on Windows conda-forge/aesara-feedstock#54
- Numpy warnings should be filtered more precisely aesara-devs/aesara#1005
- Catch Numpy "Could not locate executable" warnings aesara-devs/aesara#980
Reproduce the code example:
from contextlib import redirect_stderr, redirect_stdout
import io
import sys
import numpy.distutils.system_info
class NumpyCompatibleStdoutStringIO(io.StringIO):
"""Used as a temporary replacement of sys.stdout to capture Numpy's output.
We want to simply use io.StringIO, but this doesn't work because
Numpy expects the .encoding attribute to be a string. For io.StringIO,
this attribute is set to None and cannot be modified, hence the need for
this subclass.
(See forward_bytes_to_stdout in numpy.distutils.exec_command.)
"""
encoding = sys.stdout.encoding
# Neither of the following two work:
# stdout_sio, stderr_sio = io.StringIO(), io.StringIO()
stdout_sio, stderr_sio = NumpyCompatibleStdoutStringIO(), NumpyCompatibleStdoutStringIO()
with redirect_stdout(stdout_sio), redirect_stderr(stderr_sio):
numpy.distutils.system_info.get_info("blas_opt")Error message:
No error, but unwanted stdout:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=C:/Users/osthege/AppData/Local/Continuum/miniconda3/envs/pm3v4/Library/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-5.3.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --with-gxx-include-dir=/mingw64/include/c++/5.3.0 --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-version-specific-runtime-libs --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev5, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 5.3.0 (Rev5, Built by MSYS2 project)NumPy/Python version information:
1.19.2 3.7.9 (default, Aug 31 2020, 17:10:11) [MSC v.1916 64 bit (AMD64)]