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

Function build_libffi

cpython-windows/build.py:969–1056  ·  view source on GitHub ↗
(
    python: str,
    arch: str,
    sh_exe: pathlib.Path,
    msvc_version: str,
    dest_archive: pathlib.Path,
)

Source from the content-addressed store, hash-verified

967
968
969def build_libffi(
970 python: str,
971 arch: str,
972 sh_exe: pathlib.Path,
973 msvc_version: str,
974 dest_archive: pathlib.Path,
975):
976 with tempfile.TemporaryDirectory(prefix="libffi-build-") as td:
977 td = pathlib.Path(td)
978
979 ffi_source_path = td / "libffi"
980
981 # As of April 15, 2020, the libffi source release on GitHub doesn't
982 # have patches that we need to build. https://bugs.python.org/issue40293
983 # tracks getting a proper release. Until then, git clone the repo.
984 subprocess.run(
985 [
986 "git.exe",
987 "-c",
988 "core.autocrlf=input",
989 "clone",
990 "--single-branch",
991 "--branch",
992 "libffi",
993 "https://github.com/python/cpython-source-deps.git",
994 str(ffi_source_path),
995 ],
996 check=True,
997 )
998
999 subprocess.run(
1000 [
1001 "git.exe",
1002 "-c",
1003 "core.autocrlf=input",
1004 "checkout",
1005 "16fad4855b3d8c03b5910e405ff3a04395b39a98",
1006 ],
1007 cwd=ffi_source_path,
1008 check=True,
1009 )
1010
1011 # We build libffi by running the build script that CPython ships.
1012 python_archive = download_entry(python, BUILD)
1013 extract_tar_to_directory(python_archive, td)
1014
1015 python_entry = DOWNLOADS[python]
1016 prepare_libffi = (
1017 td
1018 / ("Python-%s" % python_entry["version"])
1019 / "PCbuild"
1020 / "prepare_libffi.bat"
1021 )
1022
1023 env = dict(os.environ)
1024 env["LIBFFI_SOURCE"] = str(ffi_source_path)
1025 env["VCVARSALL"] = str(find_vcvarsall_path(msvc_version))
1026 env["SH"] = str(sh_exe)

Callers 1

mainFunction · 0.85

Calls 5

download_entryFunction · 0.90
extract_tar_to_directoryFunction · 0.90
find_vcvarsall_pathFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected