(
python: str,
arch: str,
sh_exe: pathlib.Path,
msvc_version: str,
dest_archive: pathlib.Path,
)
| 967 | |
| 968 | |
| 969 | def 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) |
no test coverage detected