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

Function build_cpython_host

cpython-unix/build.py:393–463  ·  view source on GitHub ↗

Build binutils in the Docker image.

(
    client,
    image,
    entry,
    host_platform: str,
    target_triple: str,
    build_options: list[str],
    dest_archive,
    python_source=None,
    entry_name=None,
)

Source from the content-addressed store, hash-verified

391
392
393def build_cpython_host(
394 client,
395 image,
396 entry,
397 host_platform: str,
398 target_triple: str,
399 build_options: list[str],
400 dest_archive,
401 python_source=None,
402 entry_name=None,
403):
404 """Build binutils in the Docker image."""
405 if not python_source:
406 python_version = entry["version"]
407 archive = download_entry(entry_name, DOWNLOADS_PATH)
408 else:
409 python_version = os.environ["PYBUILD_PYTHON_VERSION"]
410 archive = DOWNLOADS_PATH / ("Python-%s.tar.xz" % python_version)
411 print("Compressing %s to %s" % (python_source, archive))
412 with archive.open("wb") as fh:
413 create_tar_from_directory(
414 fh, python_source, path_prefix="Python-%s" % python_version
415 )
416
417 with build_environment(client, image) as build_env:
418 build_env.install_toolchain(
419 BUILD,
420 host_platform,
421 target_triple,
422 binutils=install_binutils(host_platform),
423 clang=True,
424 static="static" in build_options,
425 )
426
427 build_env.copy_file(archive)
428
429 support = {
430 "build-cpython-host.sh",
431 }
432 for s in sorted(support):
433 build_env.copy_file(SUPPORT / s)
434
435 packages = {
436 "autoconf",
437 "m4",
438 }
439 for p in sorted(packages):
440 build_env.install_artifact_archive(BUILD, p, target_triple, build_options)
441
442 env = {
443 "PYTHON_VERSION": python_version,
444 }
445
446 add_target_env(env, host_platform, target_triple, build_env, build_options)
447
448 # Set environment variables allowing convenient testing for Python
449 # version ranges.
450 for v in ("3.10", "3.11", "3.12", "3.13", "3.14", "3.15"):

Callers 1

mainFunction · 0.85

Calls 12

download_entryFunction · 0.90
build_environmentFunction · 0.90
install_binutilsFunction · 0.85
add_target_envFunction · 0.85
install_toolchainMethod · 0.45
copy_fileMethod · 0.45
runMethod · 0.45
get_tools_archiveMethod · 0.45

Tested by

no test coverage detected