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

Function build_cpython

cpython-unix/build.py:702–955  ·  view source on GitHub ↗

Build CPython in a Docker image

(
    settings,
    client,
    image,
    host_platform,
    target_triple,
    build_options,
    dest_archive,
    version=None,
    python_source=None,
)

Source from the content-addressed store, hash-verified

700
701
702def build_cpython(
703 settings,
704 client,
705 image,
706 host_platform,
707 target_triple,
708 build_options,
709 dest_archive,
710 version=None,
711 python_source=None,
712):
713 """Build CPython in a Docker image'"""
714 parsed_build_options = set(build_options.split("+"))
715 entry_name = "cpython-%s" % version
716 if not python_source:
717 entry = DOWNLOADS[entry_name]
718 python_version = entry["version"]
719 python_archive = download_entry(entry_name, DOWNLOADS_PATH)
720 else:
721 entry = DOWNLOADS.get(entry_name, {})
722 python_version = os.environ["PYBUILD_PYTHON_VERSION"]
723 entry.setdefault("licenses", ["Python-2.0", "CNRI-Python"])
724 entry.setdefault("python_tag", "cp" + "".join(version.split(".")))
725 python_archive = DOWNLOADS_PATH / ("Python-%s.tar.xz" % python_version)
726 print("Compressing %s to %s" % (python_source, python_archive))
727 with python_archive.open("wb") as fh:
728 create_tar_from_directory(
729 fh, python_source, path_prefix="Python-%s" % python_version
730 )
731
732 setuptools_archive = download_entry("setuptools", DOWNLOADS_PATH)
733 pip_archive = download_entry("pip", DOWNLOADS_PATH)
734
735 ems = extension_modules_config(EXTENSION_MODULES)
736
737 setup = derive_setup_local(
738 python_archive,
739 python_version=python_version,
740 target_triple=target_triple,
741 build_options=parsed_build_options,
742 extension_modules=ems,
743 )
744
745 enabled_extensions = setup["extensions"]
746 setup_local_content = setup["setup_local"]
747 extra_make_content = setup["make_data"]
748
749 with build_environment(client, image) as build_env:
750 if settings.get("needs_toolchain"):
751 build_env.install_toolchain(
752 BUILD,
753 host_platform,
754 target_triple,
755 binutils=install_binutils(host_platform),
756 clang=True,
757 musl="musl" in target_triple,
758 static="static" in build_options,
759 )

Callers 1

mainFunction · 0.70

Calls 15

download_entryFunction · 0.90
extension_modules_configFunction · 0.90
derive_setup_localFunction · 0.90
build_environmentFunction · 0.90
target_needsFunction · 0.90
clang_toolchainFunction · 0.90
validate_python_jsonFunction · 0.90
install_binutilsFunction · 0.85
add_target_envFunction · 0.85

Tested by

no test coverage detected