1
Fork 0

Skip rustc version detection on macOS

This commit is contained in:
John Kelly 2023-04-27 17:39:58 +01:00
parent 6ce22733b9
commit 1b390f44cf

View file

@ -209,19 +209,24 @@ def default_build_triple(verbose):
# install, use their preference. This fixes most issues with Windows builds # install, use their preference. This fixes most issues with Windows builds
# being detected as GNU instead of MSVC. # being detected as GNU instead of MSVC.
default_encoding = sys.getdefaultencoding() default_encoding = sys.getdefaultencoding()
try:
version = subprocess.check_output(["rustc", "--version", "--verbose"], if sys.platform == 'darwin':
stderr=subprocess.DEVNULL) print("not using rustc detection as it is unreliable on macOS")
version = version.decode(default_encoding) print("falling back to auto-detect")
host = next(x for x in version.split('\n') if x.startswith("host: ")) else:
triple = host.split("host: ")[1] try:
if verbose: version = subprocess.check_output(["rustc", "--version", "--verbose"],
print("detected default triple {} from pre-installed rustc".format(triple)) stderr=subprocess.DEVNULL)
return triple version = version.decode(default_encoding)
except Exception as e: host = next(x for x in version.split('\n') if x.startswith("host: "))
if verbose: triple = host.split("host: ")[1]
print("pre-installed rustc not detected: {}".format(e)) if verbose:
print("falling back to auto-detect") print("detected default triple {} from pre-installed rustc".format(triple))
return triple
except Exception as e:
if verbose:
print("pre-installed rustc not detected: {}".format(e))
print("falling back to auto-detect")
required = sys.platform != 'win32' required = sys.platform != 'win32'
ostype = require(["uname", "-s"], exit=required) ostype = require(["uname", "-s"], exit=required)