From ae586e9d850b030cad7c2a5bad9ed79547d7f707 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Mon, 3 Feb 2020 16:51:03 -0700 Subject: [PR #3538] vswhere lookup: add choco path Chocolatey install path is now checked. The paths to try use a different method of getting the Windows vars - os.path.expandvars, that avoids the use of a try block or os.environ.get. Signed-off-by: Mats Wichmann --- src/engine/SCons/Tool/MSCommon/vc.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py index d22aa9b..a18a1a7 100644 --- a/src/engine/SCons/Tool/MSCommon/vc.py +++ b/src/engine/SCons/Tool/MSCommon/vc.py @@ -346,16 +346,15 @@ def find_vc_pdir_vswhere(msvc_version): # For bug 3542: also accommodate not being on C: drive. # NB: this gets called from testsuite on non-Windows platforms. # Whether that makes sense or not, don't break it for those. - pfpaths = [] - with suppress(KeyError): - # 64-bit Windows only, try it first - pfpaths.append(os.environ["ProgramFiles(x86)"]) - with suppress(KeyError): - pfpaths.append(os.environ["ProgramFiles"]) + # TODO: requested to add a user-specified path to vswhere + # and have this routine set the same var if it finds it. + pfpaths = [ + os.path.expandvars(r"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"), + os.path.expandvars(r"%ProgramFiles%\Microsoft Visual Studio\Installer"), + os.path.expandvars(r"%ChocolateyInstall%\bin"), + ] for pf in pfpaths: - vswhere_path = os.path.join( - pf, "Microsoft Visual Studio", "Installer", "vswhere.exe" - ) + vswhere_path = os.path.join(pf, "vswhere.exe") if os.path.exists(vswhere_path): break else: -- cgit v0.12