From bdc9f339c9088099de74dafdb87122dc769a4b32 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Wed, 24 Jul 2024 13:18:26 +0200 Subject: [PATCH] The msvc_sdk script failed to work properly on windows when run in folders with spaces --- msvc_build_libraries.py | 29 ++++++++++++++++------------- releasenotes.md | 1 + 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/msvc_build_libraries.py b/msvc_build_libraries.py index 0fa8b5805..458ad79d8 100755 --- a/msvc_build_libraries.py +++ b/msvc_build_libraries.py @@ -10,15 +10,26 @@ import shutil import hashlib import zipfile -import tempfile import argparse import subprocess import urllib.request +import os +import ssl +import tempfile from pathlib import Path -OUTPUT = Path("msvc_temp") # output folder +if (platform.system() == "Windows"): + print("Creating msvc_sdk for compilation without VS.") +else: + print("Creating msvc_sdk for cross platform compilation to Windows.") + +OUTPUT = Path(tempfile.mkdtemp()) # output folder SDK_OUTPUT = Path("msvc_sdk") +if (not os.environ.get('PYTHONHTTPSVERIFY', '') and + getattr(ssl, '_create_unverified_context', None)): + ssl._create_default_https_context = ssl._create_unverified_context + MANIFEST_URL = "https://aka.ms/vs/17/release/channel" def download(url): @@ -57,7 +68,6 @@ def get_msi_cabs(msi): def first(items, cond): return next(item for item in items if cond(item)) - ### parse command-line arguments @@ -135,9 +145,7 @@ def first(items, cond): if not accept or accept[0].lower() != "y": exit(0) -shutil.rmtree(OUTPUT, ignore_errors = True) shutil.rmtree(SDK_OUTPUT, ignore_errors = True) -OUTPUT.mkdir() total_download = 0 ### download Windows SDK @@ -157,7 +165,7 @@ def first(items, cond): msvc_packages.append(f"microsoft.vc.{msvc_ver}.crt.{arch}.desktop.base") msvc_packages.append(f"microsoft.vc.{msvc_ver}.crt.{arch}.store.base") msvc_packages.append(f"microsoft.vc.{msvc_ver}.asan.{arch}.base") - + for pkg in msvc_packages: p = first(packages[pkg], lambda p: p.get("language") in (None, "en-US")) for payload in p["payloads"]: @@ -226,15 +234,10 @@ def first(items, cond): SDK_OUTPUT.mkdir(exist_ok=True) - - for arch in archs: out_dir = SDK_OUTPUT / arch shutil.copytree(ucrt / arch, out_dir, dirs_exist_ok=True) - shutil.copytree(um / arch, out_dir, dirs_exist_ok=True) + shutil.copytree(um / arch, out_dir, dirs_exist_ok=True) shutil.copytree(lib / arch, out_dir, dirs_exist_ok=True) -### cleanup - -shutil.rmtree(OUTPUT, ignore_errors=True) - +print("Congratulations! The 'msvc_sdk' directory was successfully generated.") diff --git a/releasenotes.md b/releasenotes.md index 34b2199e8..7a8990f46 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -52,6 +52,7 @@ - Regression: duplicate symbols with static variable declared in macro #1248. - Unsplat with named parameters was accidentally disallowed. - Reference parameter doesn't work with vector subscript #1250. +- The msvc_sdk script failed to work properly on windows when run in folders with spaces. ### Stdlib changes - Added `remove_first_item` `remove_last_item` and `remove_item` as aliases for the `match` functions.