Skip to content

Commit 6d69886

Browse files
committed
BUG, DIST: Print os error message when the executable not exist
this patch is really important since most of the users aren't able to determine the build error when the toolchain or the built environment missing executable files of compiler, linker, assembler, etc.
1 parent 2513620 commit 6d69886

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

numpy/distutils/ccompiler.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,18 @@ def CCompiler_spawn(self, cmd, display=None):
144144
except subprocess.CalledProcessError as exc:
145145
o = exc.output
146146
s = exc.returncode
147-
except OSError:
147+
except OSError as e:
148148
# OSError doesn't have the same hooks for the exception
149149
# output, but exec_command() historically would use an
150150
# empty string for EnvironmentError (base class for
151151
# OSError)
152-
o = b''
152+
# o = b''
153+
# still that would make the end-user lost in translation!
154+
o = f"\n\n{e}\n\n\n"
155+
try:
156+
o = o.encode(sys.stdout.encoding)
157+
except AttributeError:
158+
o = o.encode('utf8')
153159
# status previously used by exec_command() for parent
154160
# of OSError
155161
s = 127

numpy/distutils/ccompiler_opt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -721,8 +721,8 @@ def _dist_test_spawn(cmd, display=None):
721721
except subprocess.CalledProcessError as exc:
722722
o = exc.output
723723
s = exc.returncode
724-
except OSError:
725-
o = b''
724+
except OSError as e:
725+
o = e
726726
s = 127
727727
else:
728728
return None

0 commit comments

Comments
 (0)