(path, msvc_version)
| 237 | |
| 238 | |
| 239 | def find_vs_path(path, msvc_version): |
| 240 | vswhere = find_vswhere() |
| 241 | |
| 242 | if msvc_version == "2019": |
| 243 | version = "[16,17)" |
| 244 | elif msvc_version == "2022": |
| 245 | version = "[17,18)" |
| 246 | elif msvc_version == "2026": |
| 247 | version = "[18,19)" |
| 248 | else: |
| 249 | raise ValueError(f"unsupported Visual Studio version: {msvc_version}") |
| 250 | |
| 251 | p = subprocess.check_output( |
| 252 | [ |
| 253 | str(vswhere), |
| 254 | "-utf8", |
| 255 | # Visual Studio 2019. |
| 256 | "-version", |
| 257 | version, |
| 258 | "-property", |
| 259 | "installationPath", |
| 260 | "-products", |
| 261 | "*", |
| 262 | ] |
| 263 | ) |
| 264 | |
| 265 | p = pathlib.Path(p.strip().decode("utf-8")) |
| 266 | |
| 267 | p = p / path |
| 268 | |
| 269 | if not p.exists(): |
| 270 | print("%s does not exist" % p) |
| 271 | sys.exit(1) |
| 272 | |
| 273 | return p |
| 274 | |
| 275 | |
| 276 | def find_msbuild(msvc_version): |
no test coverage detected