Skip to content

Commit 5fe2161

Browse files
committed
Help GraalPy discover build tools on Windows
1 parent 07ccbbe commit 5fe2161

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

cibuildwheel/platforms/windows.py

+40
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,46 @@ def setup_python(
346346
setup_setuptools_cross_compile(tmp, python_configuration, python_libs_base, env)
347347
setup_rust_cross_compile(tmp, python_configuration, python_libs_base, env)
348348

349+
if implementation_id.startswith("gp"):
350+
# GraalPy fails to discover compilers, setup the relevant environment
351+
# variables. Adapted from
352+
# https://github.com/microsoft/vswhere/wiki/Start-Developer-Command-Prompt
353+
vcpath = subprocess.check_output(
354+
[
355+
Path(os.environ["PROGRAMFILES(X86)"])
356+
/ "Microsoft Visual Studio"
357+
/ "Installer"
358+
/ "vswhere.exe",
359+
"-products",
360+
"*",
361+
"-latest",
362+
"-property",
363+
"installationPath",
364+
],
365+
text=True,
366+
).strip()
367+
log.notice(f"Discovering Visual Studio for GraalPy at {vcpath}")
368+
vcenv = dict(
369+
[
370+
envvar.strip().split("=", 1)
371+
for envvar in subprocess.check_output(
372+
[
373+
f"{vcpath}\\Common7\\Tools\\vsdevcmd.bat",
374+
"-no_logo",
375+
"-arch=amd64",
376+
"-host_arch=amd64",
377+
"&&",
378+
"set",
379+
],
380+
shell=True,
381+
text=True,
382+
)
383+
.strip()
384+
.split("\n")
385+
]
386+
)
387+
env.update(vcenv)
388+
349389
return base_python, env
350390

351391

0 commit comments

Comments
 (0)