Skip to content

Commit 329aa89

Browse files
jcfrthewtex
authored andcommitted
windows_build_wheels: Ensure ITK build uses expected compiler
1 parent 3eb8910 commit 329aa89

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

scripts/windows_build_wheels.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11

22
import errno
3+
import json
34
import os
45
import shutil
6+
import tempfile
7+
import textwrap
58

69
from contextlib import contextmanager
710
from functools import wraps
8-
from subprocess import check_call
11+
from subprocess import check_call, check_output
912

1013

1114
SCRIPT_DIR = os.path.dirname(__file__)
@@ -190,11 +193,36 @@ def build_wheel(python_version, single_wheel=False):
190193
print("# Build multiple ITK wheels")
191194
print("#")
192195

196+
try:
197+
# Because of python issue #14243, we set "delete=False" and
198+
# delete manually after process execution.
199+
script_file = tempfile.NamedTemporaryFile(
200+
delete=False, suffix=".py")
201+
script_file.write(bytearray(textwrap.dedent(
202+
"""
203+
import json
204+
from skbuild.platform_specifics.windows import WindowsPlatform
205+
# Instantiate
206+
build_platform = WindowsPlatform()
207+
generator = build_platform.default_generators[0]
208+
assert generator.name == "Ninja"
209+
print(json.dumps(generator.env))
210+
""" # noqa: E501
211+
), "utf-8"))
212+
script_file.file.flush()
213+
output = check_output([python_executable, script_file.name])
214+
build_env = json.loads(output.decode("utf-8").strip())
215+
finally:
216+
script_file.close()
217+
os.remove(script_file.name)
218+
193219
py_site_packages_path = os.path.join(
194220
SCRIPT_DIR, "..", "_skbuild", "cmake-install")
195221

196222
# Build ITK python
197-
with push_dir(directory=build_path, make_directory=True):
223+
with push_dir(directory=build_path, make_directory=True), \
224+
push_env(**build_env):
225+
198226
check_call([
199227
"cmake",
200228
"-DCMAKE_BUILD_TYPE:STRING=%s" % build_type,

0 commit comments

Comments
 (0)