Skip to content

Commit

Permalink
The msvc_sdk script failed to work properly on windows when run in fo…
Browse files Browse the repository at this point in the history
…lders with spaces
  • Loading branch information
lerno committed Jul 24, 2024
1 parent 3188d4d commit bdc9f33
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
29 changes: 16 additions & 13 deletions msvc_build_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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"]:
Expand Down Expand Up @@ -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.")
1 change: 1 addition & 0 deletions releasenotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit bdc9f33

Please sign in to comment.