Skip to content

Commit

Permalink
refactor: limit quotes to terms with spaces
Browse files Browse the repository at this point in the history
during testing it was extremely helpful having the error identify
which vswhere command had been executed, and even more helpful
being able to paste it.

since most visual studio paths have spaces in them, that's not
possible unless those terms have quotes around them, e.g.

"C:\Program Files (x86)\Microsoft\Visual Studio\...\vswhere.exe" -products ...
  • Loading branch information
kfsone committed Jun 7, 2024
1 parent 8ed9d24 commit c67c663
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cpython-windows/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,10 @@ def find_vs_path(path, msvc_version):
]
p = subprocess.check_output(cmdline)
if not p:
cmd = " ".join('"%s"' % i for i in cmdline)
print("could not find visual studio (using '%s')" % cmd)
# add quotes around any of the terms with spaces in them, so that
# the user can copy-and-paste the command.
cmdline = ['"%s"' % term if " " in term else term for term in cmdline]
print("could not find visual studio (using '%s')" % cmdline)
sys.exit(1)

# Strictly speaking the output may not be UTF-8.
Expand Down

0 comments on commit c67c663

Please sign in to comment.