Skip to content

Commit ce92c7f

Browse files
committed
Use JSON to encode env vars
1 parent 63633df commit ce92c7f

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

cibuildwheel/platforms/windows.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import json
12
import os
23
import platform as platform_module
34
import shutil
45
import subprocess
5-
import sys
66
import textwrap
77
from collections.abc import MutableMapping, Set
88
from dataclasses import dataclass
@@ -351,25 +351,22 @@ def setup_python(
351351
text=True,
352352
).strip()
353353
log.notice(f"Discovering Visual Studio for GraalPy at {vcpath}")
354-
vcvars = (
355-
subprocess.check_output(
356-
[
357-
f"{vcpath}\\Common7\\Tools\\vsdevcmd.bat",
358-
"-no_logo",
359-
"-arch=amd64",
360-
"-host_arch=amd64",
361-
"&&",
362-
"set",
363-
],
364-
shell=True,
365-
text=True,
366-
env=env,
367-
)
368-
.strip()
369-
.split("\n")
354+
vcvars = subprocess.check_output(
355+
[
356+
f"{vcpath}\\Common7\\Tools\\vsdevcmd.bat",
357+
"-no_logo",
358+
"-arch=amd64",
359+
"-host_arch=amd64",
360+
"&&",
361+
"python",
362+
"-c",
363+
"import os, json, sys; json.dump(dict(os.environ), sys.stdout);",
364+
],
365+
shell=True,
366+
text=True,
367+
env=env,
370368
)
371-
print("vcvars", vcvars, file=sys.stderr)
372-
env.update(dict([envvar.strip().split("=", 1) for envvar in vcvars]))
369+
env.update(json.loads(vcvars))
373370

374371
return base_python, env
375372

0 commit comments

Comments
 (0)