[PATCH 3 of 4] packaging: split out a utility for finding the latest Visual Studio installation

1 view
Skip to first unread message

Matt Harbison

unread,
Apr 25, 2022, 5:05:28 PM4/25/22
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1650482041 14400
# Wed Apr 20 15:14:01 2022 -0400
# Node ID bffd875df1807d6f97dff7900f3125762e01d9ff
# Parent ba3f28f0dacb1e6175c3019df61d1851c214747e
# EXP-Topic windows-py3-packaging
packaging: split out a utility for finding the latest Visual Studio installation

We'll need this to harvest the build environment variables, in order to build
the shell extension.

diff --git a/contrib/packaging/thgpackaging/util.py b/contrib/packaging/thgpackaging/util.py
--- a/contrib/packaging/thgpackaging/util.py
+++ b/contrib/packaging/thgpackaging/util.py
@@ -30,8 +30,8 @@
zf.extractall(dest)


-def find_vc_runtime_dll(x64=False):
- """Finds Visual C++ Runtime DLL to include in distribution."""
+def find_vc_installation() -> pathlib.Path:
+ """Finds the latest Visual C++ installation."""
# We invoke vswhere to find the latest Visual Studio install.
vswhere = (
pathlib.Path(os.environ["ProgramFiles(x86)"])
@@ -58,14 +58,16 @@
"installationPath",
]

- vs_install_path = pathlib.Path(
- os.fsdecode(subprocess.check_output(args).strip())
- )
+ return pathlib.Path(os.fsdecode(subprocess.check_output(args).strip()))
+

+def find_vc_runtime_dll(x64=False):
+ """Finds Visual C++ Runtime DLL to include in distribution."""
# This just gets us a path like
# C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
# Actually vcruntime140.dll is under a path like:
# VC\Redist\MSVC\<version>\<arch>\Microsoft.VC14<X>.CRT\vcruntime140.dll.
+ vs_install_path = find_vc_installation()

arch = "x64" if x64 else "x86"

Reply all
Reply to author
Forward
0 new messages