From d6c19360210791401bfb6b6fea26bfa45ca7312c Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Sat, 24 Oct 2026 13:37:35 +0200 Subject: [PATCH] setup: a source build on Windows needs Visual Studio 2022 (2019 cannot compile the C++20 sources) and the stop says so, with the ready-made engine as the way around (#3566); tests follow --- setup.py | 7 ++++--- tools/test_setup_choices.py | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index b82861fa..bf2828b1 100644 --- a/setup.py +++ b/setup.py @@ -2093,7 +2093,7 @@ def find_vcvars(cuda_v=None): args = [str(vswhere), "-latest", "-products", "*"] if cuda_v is not None: upper = "19.0" if tuple(cuda_v) >= (13, 3) else "18.0" - args += ["-version", f"[16.0,{upper})"] + args += ["-version", f"[17.0,{upper})"] # 17 = Visual Studio 2022: the sources are C++20, and nvcc silently drops -std=c++20 under 2019 (#3566) args += ["-requires", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", "-property", "installationPath"] p = out(args).strip() v = Path(p) / "VC/Auxiliary/Build/vcvars64.bat" if p else None @@ -5581,8 +5581,9 @@ def cmake_build(src, bdir, target, defs, vcvars, bat_name): # the same command then gets past it (issue #45); a second attempt only compiles what is still missing. if WIN: if vcvars is None: # #881: the build needs MSVC's environment - fail("the Visual Studio C++ build tools were not found", - "install them (Visual Studio 2019 or 2022, workload 'Desktop development with C++') and run setup again") + fail("the Visual Studio 2022 C++ build tools were not found (Visual Studio 2019 is too old: the sources are C++20)", + "install Visual Studio 2022 Build Tools (workload 'Desktop development with C++'), then run setup again; a ready-made engine " + "needs no compiler: `strata update` fetches it") bat = ROOT / bat_name q = lambda c: " ".join(f'"{x}"' if " " in str(x) else str(x) for x in c) # noqa: E731 bat.write_text(f'@echo off\r\ncall "{vcvars}" >nul\r\n{q(conf)} || exit /b 1\r\n{q(build)} && exit /b 0\r\n' diff --git a/tools/test_setup_choices.py b/tools/test_setup_choices.py index db995bb1..2643d434 100644 --- a/tools/test_setup_choices.py +++ b/tools/test_setup_choices.py @@ -236,10 +236,10 @@ class VsRange(unittest.TestCase): def test_the_range_follows_the_toolkit(self): self.assertIsNone(self.asked(None)) # #881: without CUDA vswhere gets no version range - self.assertEqual(self.asked((13, 0)), "[16.0,18.0)") - self.assertEqual(self.asked((13, 2)), "[16.0,18.0)") - self.assertEqual(self.asked((13, 3)), "[16.0,19.0)") - self.assertEqual(self.asked((14, 0)), "[16.0,19.0)") + self.assertEqual(self.asked((13, 0)), "[17.0,18.0)") + self.assertEqual(self.asked((13, 2)), "[17.0,18.0)") + self.assertEqual(self.asked((13, 3)), "[17.0,19.0)") + self.assertEqual(self.asked((14, 0)), "[17.0,19.0)") def test_vcvars_by_hand(self):