diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 27fc1707..6bfe6658 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -45,6 +45,7 @@ jobs: vcvars: - 'vcvars32.bat' - 'vcvars64.bat' + - 'vcvarsamd64_arm64.bat' profile: - 'static-noopt' - 'shared-pgo' @@ -128,3 +129,4 @@ jobs: with: name: 'cpython-install-only-${{ matrix.version }}' path: cpython-*.tar.gz + diff --git a/cpython-windows/build.py b/cpython-windows/build.py index bcb91b94..d2f9715d 100644 --- a/cpython-windows/build.py +++ b/cpython-windows/build.py @@ -794,6 +794,8 @@ def hack_props( suffix = b"x64" elif arch == "win32": suffix = None + elif arch == "arm64": + suffix = b"arm64" # TODO check it else: raise Exception("unhandled architecture: %s" % arch) @@ -1442,9 +1444,11 @@ def build_openssl_for_arch( elif arch == "amd64": configure = "VC-WIN64A" prefix = "64" + elif arch == "arm64": + configure = "VC-WIN64-ARM" + prefix = "arm64" # TODO check it ??? else: - print("invalid architecture: %s" % arch) - sys.exit(1) + raise Exception("unhandled architecture: %s" % arch) # The official CPython OpenSSL builds hack ms/uplink.c to change the # ``GetModuleHandle(NULL)`` invocation to load things from _ssl.pyd @@ -1508,6 +1512,7 @@ def build_openssl( root_32 = td / "x86" root_64 = td / "x64" + root_arm64 = td / "arm64" if arch == "x86": root_32.mkdir() @@ -1531,13 +1536,26 @@ def build_openssl( profile, jom_archive=jom_archive, ) + elif arch == "arm64": + root_64.mkdir() + build_openssl_for_arch( + perl_path, + "arm64", + openssl_archive, + nasm_archive, + root_arm64, + profile, + jom_archive=jom_archive, + ) else: - raise ValueError("unhandled arch: %s" % arch) + raise Exception("unhandled architecture: %s" % arch) install = td / "out" if arch == "x86": shutil.copytree(root_32 / "install" / "32", install / "openssl" / "win32") + elif arch == "arm64": + shutil.copytree(root_arm64 / "install" / "arm64", install / "openssl" / "arm64") else: shutil.copytree(root_64 / "install" / "64", install / "openssl" / "amd64") @@ -1641,9 +1659,14 @@ def build_libffi( if arch == "x86": args.append("-x86") artifacts_path = ffi_source_path / "i686-pc-cygwin" - else: + elif arch == "arm64": + args.append("-arm64") + artifacts_path = ffi_source_path / "aarch64-w64-cygwin" + elif arch == "amd64": args.append("-x64") artifacts_path = ffi_source_path / "x86_64-w64-cygwin" + else: + raise Exception("unhandled architecture: %s" % arch) subprocess.run(args, env=env, check=True) @@ -2001,8 +2024,11 @@ def build_cpython( elif arch == "x86": build_platform = "win32" build_directory = "win32" + elif arch == "arm64": + build_platform = "arm64" + build_directory = "arm64" else: - raise ValueError("unhandled arch: %s" % arch) + raise Exception("unhandled architecture: %s" % arch) with tempfile.TemporaryDirectory(prefix="python-build-") as td: td = pathlib.Path(td) @@ -2029,7 +2055,7 @@ def build_cpython( # We need all the OpenSSL library files in the same directory to appease # install rules. if not static: - openssl_arch = {"amd64": "amd64", "x86": "win32"}[arch] + openssl_arch = {"amd64": "amd64", "x86": "win32"}[arch] # TODO openssl_root = td / "openssl" / openssl_arch openssl_bin_path = openssl_root / "bin" openssl_lib_path = openssl_root / "lib" @@ -2434,9 +2460,14 @@ def main(): if os.environ.get("Platform") == "x86": target_triple = "i686-pc-windows-msvc" arch = "x86" - else: + elif os.environ.get("Platform") == "arm64": + target_triple = "aarch64-pc-windows-msvc" + arch = "arm64" + elif os.environ.get("Platform") == "x64": target_triple = "x86_64-pc-windows-msvc" arch = "amd64" + else: + raise Exception("unhandled architecture: %s" % os.environ.get("Platform")) # TODO need better dependency checking. openssl_archive = BUILD / ("openssl-%s-%s.tar" % (target_triple, args.profile))