From 0ed9d38117675ee1b5301ca2fde97d2e3ed55b6f Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Fri, 6 Dec 2024 11:42:40 -0600 Subject: [PATCH] Create a `pythonw.exe` copy for free-threaded Windows builds (#408) --- cpython-windows/build.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cpython-windows/build.py b/cpython-windows/build.py index 217c1bba..49fe0267 100644 --- a/cpython-windows/build.py +++ b/cpython-windows/build.py @@ -1221,8 +1221,10 @@ def build_cpython( if freethreaded: (major, minor, _) = python_version.split(".") python_exe = f"python{major}.{minor}t.exe" + pythonw_exe = f"pythonw{major}.{minor}t.exe" else: python_exe = "python.exe" + pythonw_exe = "pythonw.exe" if arch == "amd64": build_platform = "x64" @@ -1529,7 +1531,7 @@ def build_cpython( log("copying %s to %s" % (source, dest)) shutil.copyfile(source, dest) - # Rename to `python.exe` when an alternative executable is built, e.g., when + # Create a `python.exe` copy when an alternative executable is built, e.g., when # free-threading is enabled the name is `python3.13t.exe`. canonical_python_exe = install_dir / "python.exe" if not canonical_python_exe.exists(): @@ -1538,6 +1540,15 @@ def build_cpython( canonical_python_exe, ) + # Create a `pythonw.exe` copy when an alternative executable is built, e.g., when + # free-threading is enabled the name is `pythonw3.13t.exe`. + canonical_pythonw_exe = install_dir / "pythonw.exe" + if not canonical_pythonw_exe.exists(): + shutil.copy2( + install_dir / pythonw_exe, + canonical_pythonw_exe, + ) + # CPython 3.13 removed `run_tests.py`, we provide a compatibility script # for now. if meets_python_minimum_version(python_version, "3.13"):