Unverified Commit 86f8ade9 authored by Tan SU's avatar Tan SU Committed by GitHub
Browse files

[Fix] Fix collec_env() encoding error on Windows (#1905)

parent 94c071b3
...@@ -81,13 +81,15 @@ def collect_env(): ...@@ -81,13 +81,15 @@ def collect_env():
# on Windows, cl.exe is not in PATH. We need to find the path. # on Windows, cl.exe is not in PATH. We need to find the path.
# distutils.ccompiler.new_compiler() returns a msvccompiler # distutils.ccompiler.new_compiler() returns a msvccompiler
# object and after initialization, path to cl.exe is found. # object and after initialization, path to cl.exe is found.
import locale
import os import os
from distutils.ccompiler import new_compiler from distutils.ccompiler import new_compiler
ccompiler = new_compiler() ccompiler = new_compiler()
ccompiler.initialize() ccompiler.initialize()
cc = subprocess.check_output( cc = subprocess.check_output(
f'{ccompiler.cc}', stderr=subprocess.STDOUT, shell=True) f'{ccompiler.cc}', stderr=subprocess.STDOUT, shell=True)
encoding = os.device_encoding(sys.stdout.fileno()) or 'utf-8' encoding = os.device_encoding(
sys.stdout.fileno()) or locale.getpreferredencoding()
env_info['MSVC'] = cc.decode(encoding).partition('\n')[0].strip() env_info['MSVC'] = cc.decode(encoding).partition('\n')[0].strip()
env_info['GCC'] = 'n/a' env_info['GCC'] = 'n/a'
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment