@@ -144,13 +144,13 @@ def run(args, verbose=False, exception=False, **kwargs):
144144 sys .exit (err )
145145
146146
147- def require (cmd , exit = True ):
147+ def require (cmd , exit = True , encoding = sys . getdefaultencoding () ):
148148 '''Run a command, returning its output.
149149 On error,
150150 If `exit` is `True`, exit the process.
151151 Otherwise, return None.'''
152152 try :
153- return subprocess .check_output (cmd ).strip ()
153+ return subprocess .check_output (cmd ).strip (). decode ( encoding )
154154 except (subprocess .CalledProcessError , OSError ) as exc :
155155 if not exit :
156156 return None
@@ -179,10 +179,10 @@ def format_build_time(duration):
179179
180180def default_build_triple ():
181181 """Build triple as in LLVM"""
182- default_encoding = sys .getdefaultencoding ()
183182 required = not sys .platform == 'win32'
184- ostype = require (["uname" , "-s" ], exit = required ).decode (default_encoding )
185- cputype = require (['uname' , '-m' ], exit = required ).decode (default_encoding )
183+ default_encoding = sys .getdefaultencoding ()
184+ ostype = require (["uname" , "-s" ], exit = required , encoding = default_encoding )
185+ cputype = require (['uname' , '-m' ], exit = required , encoding = default_encoding )
186186
187187 if ostype is None or cputype is None :
188188 return 'x86_64-pc-windows-msvc'
@@ -215,7 +215,7 @@ def default_build_triple():
215215 # output from that option is too generic for our purposes (it will
216216 # always emit 'i386' on x86/amd64 systems). As such, isainfo -k
217217 # must be used instead.
218- cputype = require (['isainfo' , '-k' ]). decode ( default_encoding )
218+ cputype = require (['isainfo' , '-k' ])
219219 elif ostype .startswith ('MINGW' ):
220220 # msys' `uname` does not print gcc configuration, but prints msys
221221 # configuration. so we cannot believe `uname -m`:
@@ -770,10 +770,8 @@ def update_submodules(self):
770770 self .get_toml ('submodules' ) == "false" :
771771 return
772772
773- default_encoding = sys .getdefaultencoding ()
774-
775773 # check the existence and version of 'git' command
776- git_version_str = require (['git' , '--version' ]).split ()[2 ]. decode ( default_encoding )
774+ git_version_str = require (['git' , '--version' ]).split ()[2 ]
777775 self .git_version = distutils .version .LooseVersion (git_version_str )
778776
779777 slow_submodules = self .get_toml ('fast-submodules' ) == "false"
0 commit comments