@@ -144,13 +144,13 @@ def run(args, verbose=False, exception=False, **kwargs):
144
144
sys .exit (err )
145
145
146
146
147
- def require (cmd , exit = True ):
147
+ def require (cmd , exit = True , encoding = sys . getdefaultencoding () ):
148
148
'''Run a command, returning its output.
149
149
On error,
150
150
If `exit` is `True`, exit the process.
151
151
Otherwise, return None.'''
152
152
try :
153
- return subprocess .check_output (cmd ).strip ()
153
+ return subprocess .check_output (cmd ).strip (). decode ( encoding )
154
154
except (subprocess .CalledProcessError , OSError ) as exc :
155
155
if not exit :
156
156
return None
@@ -179,10 +179,10 @@ def format_build_time(duration):
179
179
180
180
def default_build_triple ():
181
181
"""Build triple as in LLVM"""
182
- default_encoding = sys .getdefaultencoding ()
183
182
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 )
186
186
187
187
if ostype is None or cputype is None :
188
188
return 'x86_64-pc-windows-msvc'
@@ -215,7 +215,7 @@ def default_build_triple():
215
215
# output from that option is too generic for our purposes (it will
216
216
# always emit 'i386' on x86/amd64 systems). As such, isainfo -k
217
217
# must be used instead.
218
- cputype = require (['isainfo' , '-k' ]). decode ( default_encoding )
218
+ cputype = require (['isainfo' , '-k' ])
219
219
elif ostype .startswith ('MINGW' ):
220
220
# msys' `uname` does not print gcc configuration, but prints msys
221
221
# configuration. so we cannot believe `uname -m`:
@@ -770,10 +770,8 @@ def update_submodules(self):
770
770
self .get_toml ('submodules' ) == "false" :
771
771
return
772
772
773
- default_encoding = sys .getdefaultencoding ()
774
-
775
773
# 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 ]
777
775
self .git_version = distutils .version .LooseVersion (git_version_str )
778
776
779
777
slow_submodules = self .get_toml ('fast-submodules' ) == "false"
0 commit comments