Skip to content

Commit 5c33dca

Browse files
hoodmanealex
andauthored
Add the rustc version to debug assistance output when setup.py fails (#7382)
* Add the rustc version to debug assistance output when setup.py fails * Update setup.py Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com> * Apply formatter, better string manipulation * Try again with string manipulation * check=True * apply formatter Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
1 parent 2bd0dda commit 5c33dca

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

setup.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
import os
88
import platform
9+
import re
10+
import shutil
11+
import subprocess
912
import sys
1013

1114
from setuptools import setup
@@ -89,6 +92,22 @@
8992
except pkg_resources.DistributionNotFound:
9093
version = "n/a"
9194
print(f" {dist}: {version}")
95+
version = "n/a"
96+
if shutil.which("rustc") is not None:
97+
try:
98+
# If for any reason `rustc --version` fails, silently ignore it
99+
rustc_output = subprocess.run(
100+
["rustc", "--version"],
101+
capture_output=True,
102+
timeout=0.5,
103+
encoding="utf8",
104+
check=True,
105+
).stdout
106+
version = re.sub("^rustc ", "", rustc_output.strip())
107+
except subprocess.SubprocessError:
108+
pass
109+
print(f" rustc: {version}")
110+
92111
print(
93112
"""\
94113
=============================DEBUG ASSISTANCE=============================

0 commit comments

Comments
 (0)