@@ -438,6 +438,8 @@ def hack_props(
438438 suffix = b"-x64"
439439 elif arch == "win32" :
440440 suffix = b""
441+ elif arch == "arm64" :
442+ suffix = b"arm64"
441443 else :
442444 raise Exception ("unhandled architecture: %s" % arch )
443445
@@ -917,9 +919,11 @@ def build_openssl_for_arch(
917919 elif arch == "amd64" :
918920 configure = "VC-WIN64A"
919921 prefix = "64"
922+ elif arch == "arm64" :
923+ configure = "VC-WIN64-ARM"
924+ prefix = "arm64" # TODO check it ???
920925 else :
921- print ("invalid architecture: %s" % arch )
922- sys .exit (1 )
926+ raise Exception ("unhandled architecture: %s" % arch )
923927
924928 # The official CPython OpenSSL builds hack ms/uplink.c to change the
925929 # ``GetModuleHandle(NULL)`` invocation to load things from _ssl.pyd
@@ -988,6 +992,7 @@ def build_openssl(
988992
989993 root_32 = td / "x86"
990994 root_64 = td / "x64"
995+ root_arm64 = td / "arm64"
991996
992997 if arch == "x86" :
993998 root_32 .mkdir ()
@@ -1011,13 +1016,27 @@ def build_openssl(
10111016 root_64 ,
10121017 jom_archive = jom_archive ,
10131018 )
1019+ elif arch == "arm64" :
1020+ root_64 .mkdir ()
1021+ build_openssl_for_arch (
1022+ perl_path ,
1023+ "arm64" ,
1024+ openssl_archive ,
1025+ nasm_archive ,
1026+ root_arm64 ,
1027+ jom_archive = jom_archive ,
1028+ )
10141029 else :
1015- raise ValueError ("unhandled arch : %s" % arch )
1030+ raise Exception ("unhandled architecture : %s" % arch )
10161031
10171032 install = td / "out"
10181033
10191034 if arch == "x86" :
10201035 shutil .copytree (root_32 / "install" / "32" , install / "openssl" / "win32" )
1036+ elif arch == "arm64" :
1037+ shutil .copytree (
1038+ root_arm64 / "install" / "arm64" , install / "openssl" / "arm64"
1039+ )
10211040 else :
10221041 shutil .copytree (root_64 / "install" / "64" , install / "openssl" / "amd64" )
10231042
@@ -1088,9 +1107,14 @@ def build_libffi(
10881107 if arch == "x86" :
10891108 args .append ("-x86" )
10901109 artifacts_path = ffi_source_path / "i686-pc-cygwin"
1091- else :
1110+ elif arch == "arm64" :
1111+ args .append ("-arm64" )
1112+ artifacts_path = ffi_source_path / "aarch64-w64-cygwin"
1113+ elif arch == "amd64" :
10921114 args .append ("-x64" )
10931115 artifacts_path = ffi_source_path / "x86_64-w64-cygwin"
1116+ else :
1117+ raise Exception ("unhandled architecture: %s" % arch )
10941118
10951119 subprocess .run (args , env = env , check = True )
10961120
@@ -1460,8 +1484,11 @@ def build_cpython(
14601484 elif arch == "x86" :
14611485 build_platform = "win32"
14621486 build_directory = "win32"
1487+ elif arch == "arm64" :
1488+ build_platform = "arm64"
1489+ build_directory = "arm64"
14631490 else :
1464- raise ValueError ("unhandled arch : %s" % arch )
1491+ raise Exception ("unhandled architecture : %s" % arch )
14651492
14661493 with tempfile .TemporaryDirectory (prefix = "python-build-" ) as td :
14671494 td = pathlib .Path (td )
@@ -1491,7 +1518,7 @@ def build_cpython(
14911518
14921519 # We need all the OpenSSL library files in the same directory to appease
14931520 # install rules.
1494- openssl_arch = {"amd64" : "amd64" , "x86" : "win32" }[arch ]
1521+ openssl_arch = {"amd64" : "amd64" , "x86" : "win32" , "arm64" : "arm64" }[arch ]
14951522 openssl_root = td / "openssl" / openssl_arch
14961523 openssl_bin_path = openssl_root / "bin"
14971524 openssl_lib_path = openssl_root / "lib"
@@ -1930,9 +1957,14 @@ def main() -> None:
19301957 if os .environ .get ("Platform" ) == "x86" :
19311958 target_triple = "i686-pc-windows-msvc"
19321959 arch = "x86"
1933- else :
1960+ elif os .environ .get ("Platform" ) == "arm64" :
1961+ target_triple = "aarch64-pc-windows-msvc"
1962+ arch = "arm64"
1963+ elif os .environ .get ("Platform" ) == "x64" :
19341964 target_triple = "x86_64-pc-windows-msvc"
19351965 arch = "amd64"
1966+ else :
1967+ raise Exception ("unhandled architecture: %s" % os .environ .get ("Platform" ))
19361968
19371969 # TODO need better dependency checking.
19381970
0 commit comments