MCPcopy
hub / github.com/astral-sh/python-build-standalone / build_cpython

Function build_cpython

cpython-windows/build.py:1363–1926  ·  view source on GitHub ↗
(
    python_entry_name: str,
    target_triple: str,
    arch: str,
    build_options: str,
    msvc_version: str,
    windows_sdk_version: str,
    openssl_archive,
    libffi_archive,
    openssl_entry: str,
)

Source from the content-addressed store, hash-verified

1361
1362
1363def build_cpython(
1364 python_entry_name: str,
1365 target_triple: str,
1366 arch: str,
1367 build_options: str,
1368 msvc_version: str,
1369 windows_sdk_version: str,
1370 openssl_archive,
1371 libffi_archive,
1372 openssl_entry: str,
1373) -> pathlib.Path:
1374 parsed_build_options = set(build_options.split("+"))
1375 pgo = "pgo" in parsed_build_options
1376 freethreaded = "freethreaded" in parsed_build_options
1377
1378 msbuild = find_msbuild(msvc_version)
1379 log("found MSBuild at %s" % msbuild)
1380
1381 # The python.props file keys off MSBUILD, so it needs to be set.
1382 os.environ["MSBUILD"] = str(msbuild)
1383
1384 python_archive = download_entry(python_entry_name, BUILD)
1385 entry = DOWNLOADS[python_entry_name]
1386 python_version = entry["version"]
1387
1388 zlib_entry = (
1389 "zlib-ng" if meets_python_minimum_version(python_version, "3.14") else "zlib"
1390 )
1391
1392 bzip2_archive = download_entry("bzip2", BUILD)
1393 sqlite_archive = download_entry("sqlite", BUILD)
1394 xz_archive = download_entry("xz", BUILD)
1395 zlib_archive = download_entry(zlib_entry, BUILD)
1396
1397 setuptools_wheel = download_entry("setuptools", BUILD)
1398 pip_wheel = download_entry("pip", BUILD)
1399
1400 # We use a prebuild tcl/tk from the upstream CPython project.
1401 # Tcl/tk 8.6.14+ has an additional runtime dependency. We are conservative and
1402 # use an old version prior to CPython 3.14. The older tck/tk release
1403 # is not available for arm64 so we use a newer release there as well.
1404 # On CPython 3.14+ we match the version included in the Python.org release.
1405 if meets_python_minimum_version(python_version, "3.15"):
1406 tk_bin_entry = "tk-windows-bin-903"
1407 elif meets_python_minimum_version(python_version, "3.14") or arch == "arm64":
1408 tk_bin_entry = "tk-windows-bin-8614"
1409 else:
1410 tk_bin_entry = "tk-windows-bin-8612"
1411 tk_bin_archive = download_entry(
1412 tk_bin_entry, BUILD, local_name="tk-windows-bin.tar.gz"
1413 )
1414
1415 # On CPython 3.14+, zstd is included
1416 if meets_python_minimum_version(python_version, "3.14"):
1417 zstd_archive = download_entry("zstd", BUILD)
1418 else:
1419 zstd_archive = None
1420

Callers 1

mainFunction · 0.70

Calls 15

download_entryFunction · 0.90
extract_tar_to_directoryFunction · 0.90
parse_config_cFunction · 0.90
validate_python_jsonFunction · 0.90
normalize_tar_archiveFunction · 0.90
find_msbuildFunction · 0.85
apply_source_patchFunction · 0.85
hack_project_filesFunction · 0.85
run_msbuildFunction · 0.85

Tested by

no test coverage detected