@@ -438,6 +438,8 @@ def hack_props(
438
438
suffix = b"-x64"
439
439
elif arch == "win32" :
440
440
suffix = b""
441
+ elif arch == "arm64" :
442
+ suffix = b""
441
443
else :
442
444
raise Exception ("unhandled architecture: %s" % arch )
443
445
@@ -917,9 +919,11 @@ def build_openssl_for_arch(
917
919
elif arch == "amd64" :
918
920
configure = "VC-WIN64A"
919
921
prefix = "64"
922
+ elif arch == "arm64" :
923
+ configure = "VC-WIN64-ARM"
924
+ prefix = "arm64"
920
925
else :
921
- print ("invalid architecture: %s" % arch )
922
- sys .exit (1 )
926
+ raise Exception ("unhandled architecture: %s" % arch )
923
927
924
928
# The official CPython OpenSSL builds hack ms/uplink.c to change the
925
929
# ``GetModuleHandle(NULL)`` invocation to load things from _ssl.pyd
@@ -936,6 +940,7 @@ def build_openssl_for_arch(
936
940
str (perl_path ),
937
941
"Configure" ,
938
942
configure ,
943
+ "enable-applink" ,
939
944
"no-idea" ,
940
945
"no-mdc2" ,
941
946
"no-tests" ,
@@ -988,6 +993,7 @@ def build_openssl(
988
993
989
994
root_32 = td / "x86"
990
995
root_64 = td / "x64"
996
+ root_arm64 = td / "arm64"
991
997
992
998
if arch == "x86" :
993
999
root_32 .mkdir ()
@@ -1011,13 +1017,28 @@ def build_openssl(
1011
1017
root_64 ,
1012
1018
jom_archive = jom_archive ,
1013
1019
)
1020
+ elif arch == "arm64" :
1021
+ root_arm64 .mkdir ()
1022
+ build_openssl_for_arch (
1023
+ perl_path ,
1024
+ "arm64" ,
1025
+ openssl_archive ,
1026
+ openssl_version ,
1027
+ nasm_archive ,
1028
+ root_arm64 ,
1029
+ jom_archive = jom_archive ,
1030
+ )
1014
1031
else :
1015
- raise ValueError ("unhandled arch : %s" % arch )
1032
+ raise Exception ("unhandled architecture : %s" % arch )
1016
1033
1017
1034
install = td / "out"
1018
1035
1019
1036
if arch == "x86" :
1020
1037
shutil .copytree (root_32 / "install" / "32" , install / "openssl" / "win32" )
1038
+ elif arch == "arm64" :
1039
+ shutil .copytree (
1040
+ root_arm64 / "install" / "arm64" , install / "openssl" / "arm64"
1041
+ )
1021
1042
else :
1022
1043
shutil .copytree (root_64 / "install" / "64" , install / "openssl" / "amd64" )
1023
1044
@@ -1088,9 +1109,14 @@ def build_libffi(
1088
1109
if arch == "x86" :
1089
1110
args .append ("-x86" )
1090
1111
artifacts_path = ffi_source_path / "i686-pc-cygwin"
1091
- else :
1112
+ elif arch == "arm64" :
1113
+ args .append ("-arm64" )
1114
+ artifacts_path = ffi_source_path / "aarch64-w64-cygwin"
1115
+ elif arch == "amd64" :
1092
1116
args .append ("-x64" )
1093
1117
artifacts_path = ffi_source_path / "x86_64-w64-cygwin"
1118
+ else :
1119
+ raise Exception ("unhandled architecture: %s" % arch )
1094
1120
1095
1121
subprocess .run (args , env = env , check = True )
1096
1122
@@ -1460,8 +1486,11 @@ def build_cpython(
1460
1486
elif arch == "x86" :
1461
1487
build_platform = "win32"
1462
1488
build_directory = "win32"
1489
+ elif arch == "arm64" :
1490
+ build_platform = "arm64"
1491
+ build_directory = "arm64"
1463
1492
else :
1464
- raise ValueError ("unhandled arch : %s" % arch )
1493
+ raise Exception ("unhandled architecture : %s" % arch )
1465
1494
1466
1495
with tempfile .TemporaryDirectory (prefix = "python-build-" ) as td :
1467
1496
td = pathlib .Path (td )
@@ -1491,7 +1520,7 @@ def build_cpython(
1491
1520
1492
1521
# We need all the OpenSSL library files in the same directory to appease
1493
1522
# install rules.
1494
- openssl_arch = {"amd64" : "amd64" , "x86" : "win32" }[arch ]
1523
+ openssl_arch = {"amd64" : "amd64" , "x86" : "win32" , "arm64" : "arm64" }[arch ]
1495
1524
openssl_root = td / "openssl" / openssl_arch
1496
1525
openssl_bin_path = openssl_root / "bin"
1497
1526
openssl_lib_path = openssl_root / "lib"
@@ -1930,9 +1959,14 @@ def main() -> None:
1930
1959
if os .environ .get ("Platform" ) == "x86" :
1931
1960
target_triple = "i686-pc-windows-msvc"
1932
1961
arch = "x86"
1933
- else :
1962
+ elif os .environ .get ("Platform" ) == "arm64" :
1963
+ target_triple = "aarch64-pc-windows-msvc"
1964
+ arch = "arm64"
1965
+ elif os .environ .get ("Platform" ) == "x64" :
1934
1966
target_triple = "x86_64-pc-windows-msvc"
1935
1967
arch = "amd64"
1968
+ else :
1969
+ raise Exception ("unhandled architecture: %s" % os .environ .get ("Platform" ))
1936
1970
1937
1971
# TODO need better dependency checking.
1938
1972
0 commit comments