Skip to content

Fails to build on Win 11 with Preview visual studio #268

Open
@kfsone

Description

@kfsone

Command line:

py.exe build-windows.py --profile noopt --vs 2022 --python cpython-3.12 --sh c:\cygwin64\bin\bash.exe

downloads strawberry perl, process libffi, and then fails with the obtuse: VC\Auxiliary\Build\vcvarsall.bat not found.

This appears to be two fold:

1- the result of the subcommand in find_vs_path is not checked for emptiness,
2- the command is not passing the "-prerelease" option to vswhere,

An easy fix would be:

diff --git a/cpython-windows/build.py b/cpython-windows/build.py
index bc97cd5..66ff6a1 100644
--- a/cpython-windows/build.py
+++ b/cpython-windows/build.py
@@ -233,18 +233,22 @@ def find_vs_path(path, msvc_version):
     else:
         raise ValueError(f"unsupported Visual Studio version: {msvc_version}")

-    p = subprocess.check_output(
-        [
-            str(vswhere),
-            # Visual Studio 2019.
-            "-version",
-            version,
-            "-property",
-            "installationPath",
-            "-products",
-            "*",
-        ]
-    )
+    cmdline = [
+        str(vswhere),
+        # Visual Studio 2019.
+        "-version",
+        version,
+        "-property",
+        "installationPath",
+        "-prerelease",
+        "-products",
+        "*",
+    ]
+    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)
+        sys.exit(1)

But I suspect this would kick the can down the road to an additional problem if you had vs2022 and vs2022 preview installed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingplatform:windowsSpecific to the Windows platform

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions