question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: `numpy.distutils.system_info.get_info("blas_opt")` has unsuppressable stdout side effects

See original GitHub issue

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:

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)]

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
michaelosthegecommented, Jul 8, 2022

Yes, Windows only and probably a regression of some sort.

Thanks for the code pointer. I’ll investigate and attempt to fix tomorrow!

0reactions
michaelosthegecommented, Jul 9, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found