@@ -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" # TODO check it ???
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
@@ -988,6 +992,7 @@ def build_openssl(
988
992
989
993
root_32 = td / "x86"
990
994
root_64 = td / "x64"
995
+ root_arm64 = td / "arm64"
991
996
992
997
if arch == "x86" :
993
998
root_32 .mkdir ()
@@ -1011,13 +1016,28 @@ def build_openssl(
1011
1016
root_64 ,
1012
1017
jom_archive = jom_archive ,
1013
1018
)
1019
+ elif arch == "arm64" :
1020
+ root_64 .mkdir ()
1021
+ build_openssl_for_arch (
1022
+ perl_path ,
1023
+ "arm64" ,
1024
+ openssl_archive ,
1025
+ openssl_version ,
1026
+ nasm_archive ,
1027
+ root_arm64 ,
1028
+ jom_archive = jom_archive ,
1029
+ )
1014
1030
else :
1015
- raise ValueError ("unhandled arch : %s" % arch )
1031
+ raise Exception ("unhandled architecture : %s" % arch )
1016
1032
1017
1033
install = td / "out"
1018
1034
1019
1035
if arch == "x86" :
1020
1036
shutil .copytree (root_32 / "install" / "32" , install / "openssl" / "win32" )
1037
+ elif arch == "arm64" :
1038
+ shutil .copytree (
1039
+ root_arm64 / "install" / "arm64" , install / "openssl" / "arm64"
1040
+ )
1021
1041
else :
1022
1042
shutil .copytree (root_64 / "install" / "64" , install / "openssl" / "amd64" )
1023
1043
@@ -1088,9 +1108,14 @@ def build_libffi(
1088
1108
if arch == "x86" :
1089
1109
args .append ("-x86" )
1090
1110
artifacts_path = ffi_source_path / "i686-pc-cygwin"
1091
- else :
1111
+ elif arch == "arm64" :
1112
+ args .append ("-arm64" )
1113
+ artifacts_path = ffi_source_path / "aarch64-w64-cygwin"
1114
+ elif arch == "amd64" :
1092
1115
args .append ("-x64" )
1093
1116
artifacts_path = ffi_source_path / "x86_64-w64-cygwin"
1117
+ else :
1118
+ raise Exception ("unhandled architecture: %s" % arch )
1094
1119
1095
1120
subprocess .run (args , env = env , check = True )
1096
1121
@@ -1460,8 +1485,11 @@ def build_cpython(
1460
1485
elif arch == "x86" :
1461
1486
build_platform = "win32"
1462
1487
build_directory = "win32"
1488
+ elif arch == "arm64" :
1489
+ build_platform = "arm64"
1490
+ build_directory = "arm64"
1463
1491
else :
1464
- raise ValueError ("unhandled arch : %s" % arch )
1492
+ raise Exception ("unhandled architecture : %s" % arch )
1465
1493
1466
1494
with tempfile .TemporaryDirectory (prefix = "python-build-" ) as td :
1467
1495
td = pathlib .Path (td )
@@ -1491,7 +1519,7 @@ def build_cpython(
1491
1519
1492
1520
# We need all the OpenSSL library files in the same directory to appease
1493
1521
# install rules.
1494
- openssl_arch = {"amd64" : "amd64" , "x86" : "win32" }[arch ]
1522
+ openssl_arch = {"amd64" : "amd64" , "x86" : "win32" , "arm64" : "arm64" }[arch ]
1495
1523
openssl_root = td / "openssl" / openssl_arch
1496
1524
openssl_bin_path = openssl_root / "bin"
1497
1525
openssl_lib_path = openssl_root / "lib"
@@ -1930,9 +1958,14 @@ def main() -> None:
1930
1958
if os .environ .get ("Platform" ) == "x86" :
1931
1959
target_triple = "i686-pc-windows-msvc"
1932
1960
arch = "x86"
1933
- else :
1961
+ elif os .environ .get ("Platform" ) == "arm64" :
1962
+ target_triple = "aarch64-pc-windows-msvc"
1963
+ arch = "arm64"
1964
+ elif os .environ .get ("Platform" ) == "x64" :
1934
1965
target_triple = "x86_64-pc-windows-msvc"
1935
1966
arch = "amd64"
1967
+ else :
1968
+ raise Exception ("unhandled architecture: %s" % os .environ .get ("Platform" ))
1936
1969
1937
1970
# TODO need better dependency checking.
1938
1971
0 commit comments