1010
1111import os
1212import platform
13+ from distutils .core import Distribution
14+ from distutils import sysconfig
1315from cffi import FFI
1416
1517# Compile in debug mode.
5153
5254
5355def get_config ():
54- from distutils .core import Distribution
55- from distutils .sysconfig import get_config_vars
56-
57- get_config_vars () # workaround for a bug of distutils, e.g. on OS/X
56+ sysconfig .get_config_vars () # workaround for a bug of distutils, e.g. on OS/X
5857 config = Distribution ().get_command_obj ("config" )
5958 return config
6059
@@ -73,15 +72,28 @@ def _get_target_platform():
7372 except ValueError :
7473 pass
7574
76- return platform .machine ()
75+ arch = os .environ .get ("CIBW_ARCH" , platform .machine ())
76+ return arch
7777
7878
7979is_windows = platform .system () == "Windows"
8080is_macos = platform .system () == "Darwin"
81-
8281target_platform = _get_target_platform ()
8382is_x86_64 = target_platform in ("i686" , "x86" , "x86_64" , "AMD64" )
8483
84+ if is_windows and target_platform == "ARM64" :
85+ os .environ ["CC" ] = "clang-cl"
86+ os .environ ["CXX" ] = "clang-cl"
87+ os .environ ["LD" ] = "lld-link"
88+ # Prevent setuptools from re-enabling MSVC
89+ os .environ ["DISTUTILS_USE_SDK" ] = "1"
90+ os .environ ["MSSdk" ] = "1"
91+ print ("Using LLVM/clang-cl for Windows ARM64" )
92+ else :
93+ print (
94+ f"Using default compiler { sysconfig .get_config_var ('CC' )} for arch={ target_platform } "
95+ )
96+
8597# Compiler flags.
8698MSVC_CFLAGS = [
8799 "/O2" , # Maximize speed
0 commit comments