@@ -110,7 +110,11 @@ def _ensure_nuget() -> Path:
110
110
return nuget
111
111
112
112
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
114
118
base_output_dir = CIBW_CACHE_PATH / "nuget-cpython"
115
119
nuget_args = get_nuget_args (version , arch , free_threaded , base_output_dir )
116
120
installation_path = base_output_dir / (nuget_args [0 ] + "." + version ) / "tools"
@@ -229,21 +233,14 @@ def setup_python(
229
233
log .step (f"Installing Python { implementation_id } ..." )
230
234
if implementation_id .startswith ("cp" ):
231
235
native_arch = platform_module .machine ()
232
- free_threaded = implementation_id . endswith ( "t" )
236
+ base_python = install_cpython ( python_configuration )
233
237
if python_configuration .arch == "ARM64" != native_arch :
234
238
# To cross-compile for ARM64, we need a native CPython to run the
235
239
# build, and a copy of the ARM64 import libraries ('.\libs\*.lib')
236
240
# 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"
241
242
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 )
247
244
elif implementation_id .startswith ("pp" ):
248
245
assert python_configuration .url is not None
249
246
base_python = install_pypy (tmp , python_configuration .arch , python_configuration .url )
0 commit comments