Skip to content

Commit

Permalink
Merge pull request #392 from davidhewitt/pep517-output
Browse files Browse the repository at this point in the history
pep517: print output on build failure
  • Loading branch information
konstin authored Jan 8, 2021
2 parents 0fc16fe + f8069c1 commit abb34c4
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions maturin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,17 @@ def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
command.extend(get_config_options())

print("Running `{}`".format(" ".join(command)))
try:
output = subprocess.check_output(command)
except subprocess.CalledProcessError as e:
print("Error: {}".format(e))
sys.exit(1)
sys.stdout.buffer.write(output)
sys.stdout.flush()
output = output.decode(errors="replace")
result = subprocess.run(command, stdout=subprocess.PIPE)
sys.stdout.buffer.write(result.stdout)
sys.stdout.flush()
if result.returncode != 0:
print("Error: command {} returned non-zero exit status {}".format(
command,
result.returncode
))
sys.exit(1)
output = result.stdout.decode(errors="replace")
wheel_path = output.strip().splitlines()[-1]
filename = os.path.basename(wheel_path)
shutil.copy2(wheel_path, os.path.join(wheel_directory, filename))
Expand All @@ -78,14 +81,17 @@ def build_sdist(sdist_directory, config_settings=None):
command = ["maturin", "pep517", "write-sdist", "--sdist-directory", sdist_directory]

print("Running `{}`".format(" ".join(command)))
try:
output = subprocess.check_output(command)
except subprocess.CalledProcessError as e:
print(e)
sys.exit(1)
sys.stdout.buffer.write(output)
sys.stdout.flush()
output = output.decode(errors="replace")
result = subprocess.run(command, stdout=subprocess.PIPE)
sys.stdout.buffer.write(result.stdout)
sys.stdout.flush()
if result.returncode != 0:
print("Error: command {} returned non-zero exit status {}".format(
command,
result.returncode
))
sys.exit(1)
output = result.stdout.decode(errors="replace")
return output.strip().splitlines()[-1]


Expand Down

0 comments on commit abb34c4

Please sign in to comment.