Skip to content

Commit b613249

Browse files
mayeuthenryiii
authored andcommitted
chore: pass a PythonConfiguration to install_cpython
1 parent 3992d57 commit b613249

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

cibuildwheel/windows.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ def _ensure_nuget() -> Path:
110110
return nuget
111111

112112

113-
def install_cpython(version: str, arch: str, free_threaded: bool) -> Path:
113+
def install_cpython(configuration: PythonConfiguration, arch: str | None = None) -> Path:
114+
version = configuration.version
115+
free_threaded = "t-" in configuration.identifier
116+
if arch is None:
117+
arch = configuration.arch
114118
base_output_dir = CIBW_CACHE_PATH / "nuget-cpython"
115119
nuget_args = get_nuget_args(version, arch, free_threaded, base_output_dir)
116120
installation_path = base_output_dir / (nuget_args[0] + "." + version) / "tools"
@@ -229,21 +233,14 @@ def setup_python(
229233
log.step(f"Installing Python {implementation_id}...")
230234
if implementation_id.startswith("cp"):
231235
native_arch = platform_module.machine()
232-
free_threaded = implementation_id.endswith("t")
236+
base_python = install_cpython(python_configuration)
233237
if python_configuration.arch == "ARM64" != native_arch:
234238
# To cross-compile for ARM64, we need a native CPython to run the
235239
# build, and a copy of the ARM64 import libraries ('.\libs\*.lib')
236240
# for any extension modules.
237-
python_libs_base = install_cpython(
238-
python_configuration.version, python_configuration.arch, free_threaded
239-
)
240-
python_libs_base = python_libs_base.parent / "libs"
241+
python_libs_base = base_python.parent / "libs"
241242
log.step(f"Installing native Python {native_arch} for cross-compilation...")
242-
base_python = install_cpython(python_configuration.version, native_arch, free_threaded)
243-
else:
244-
base_python = install_cpython(
245-
python_configuration.version, python_configuration.arch, free_threaded
246-
)
243+
base_python = install_cpython(python_configuration, arch=native_arch)
247244
elif implementation_id.startswith("pp"):
248245
assert python_configuration.url is not None
249246
base_python = install_pypy(tmp, python_configuration.arch, python_configuration.url)

0 commit comments

Comments
 (0)