Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gracefully handle empty output from vswhere.exe #1159

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions src/build_tools/vs_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,24 @@ def get_vcvarsall(
msgs += ['-----stderr-----', stderr]
raise ChildProcessError('\n'.join(msgs))

vcvarsall = pathlib.Path(stdout.splitlines()[0])
if not vcvarsall.exists():
msg = 'Could not find vcvarsall.bat.'
if arch.endswith('arm64'):
msg += (
' Make sure Microsoft.VisualStudio.Component.VC.Tools.ARM64 is'
' installed.'
)
else:
msg += (
' Consider using --vcvarsall_path option e.g.\n'
r' --vcvarsall_path=C:\VS\VC\Auxiliary\Build\vcvarsall.bat'
)
raise FileNotFoundError(msg)

return vcvarsall
lines = stdout.splitlines()
if len(lines) > 0:
vcvarsall = pathlib.Path(lines[0])
if vcvarsall.exists():
return vcvarsall

msg = 'Could not find vcvarsall.bat.'
if arch.endswith('arm64'):
msg += (
' Make sure Microsoft.VisualStudio.Component.VC.Tools.ARM64 is'
' installed.'
)
else:
msg += (
' Consider using --vcvarsall_path option e.g.\n'
r' --vcvarsall_path=C:\VS\VC\Auxiliary\Build\vcvarsall.bat'
)
raise FileNotFoundError(msg)


def get_vs_env_vars(
Expand Down