Skip to content

Commit 2036be6

Browse files
committed
better error reporting
1 parent b195c3f commit 2036be6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

setuptools_rust/build.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,12 @@ def build_extension(self, ext):
9797
try:
9898
output = subprocess.check_output(args, env=env)
9999
except subprocess.CalledProcessError as e:
100+
output = e.output
101+
if isinstance(output, bytes):
102+
output = e.output.decode('latin-1').strip()
100103
raise CompileError(
101-
"cargo failed with code: %d\n%s" % (e.returncode, e.output))
104+
"cargo failed with code: %d\n%s" % (e.returncode, output))
105+
102106
except OSError:
103107
raise DistutilsExecError(
104108
"Unable to execute 'cargo' - this package "
@@ -107,8 +111,8 @@ def build_extension(self, ext):
107111
if not quiet:
108112
if isinstance(output, bytes):
109113
output = output.decode('latin-1')
110-
if output:
111-
print(output, file=sys.stderr)
114+
if output:
115+
print(output, file=sys.stderr)
112116

113117
# Find the shared library that cargo hopefully produced and copy
114118
# it into the build directory as if it were produced by build_ext.

0 commit comments

Comments
 (0)