77
88MACHINE_TYPE = {
99 "linux" : "ubuntu-latest" ,
10- "macos" : "macos-12 " ,
10+ "macos" : "macos-latest " ,
1111 "windows" : "windows-latest" ,
1212}
13- M1_RUNNER = "macos-14"
1413
1514CIBW_BUILD = os .environ .get ("CIBW_BUILD" , "*" )
1615CIBW_ARCHS = os .environ .get ("CIBW_ARCHS" , "auto" )
@@ -37,10 +36,7 @@ def load_build_targets(targets):
3736
3837def get_os (target ):
3938 if "macos" in target :
40- if get_cibw_archs (target ) in {"arm64" , "universal2" }:
41- return M1_RUNNER
42- else :
43- return MACHINE_TYPE ["macos" ]
39+ return MACHINE_TYPE ["macos" ]
4440 if "win" in target :
4541 return MACHINE_TYPE ["windows" ]
4642 return MACHINE_TYPE ["linux" ]
@@ -53,9 +49,32 @@ def get_cibw_build(target):
5349
5450
5551def get_cibw_archs (target ):
56- for arch in ["aarch64" , "ppc64le" , "s390x" , "armv7l" , "arm64" , "universal2" ]:
57- if target .endswith (arch ):
58- return arch
52+ """
53+ Handle non-native architectures
54+
55+ cibw allows running non-native builds on various platforms:
56+ https://cibuildwheel.pypa.io/en/stable/options/#archs
57+
58+ This logic overrides the "auto" flag based on OS and a list of supported
59+ non-native arch if a non-native arch is given for a particular platform in
60+ targets, rather than the user having to do this manually.
61+ """
62+ platform_archs = {
63+ # We now cross compile x86_64 on arm64 by default
64+ "macos" : ["universal2" , "x86_64" ],
65+ # This is a list of supported eumulated arches on linux
66+ "linux" : ["aarch64" , "ppc64le" , "s390x" , "armv7l" ],
67+ }
68+ for platform , archs in platform_archs .items ():
69+ if platform in target :
70+ for arch in archs :
71+ if target .endswith (arch ):
72+ return arch
73+
74+ # If no explict arch has been specified build both arm64 and x86_64 on macos
75+ if "macos" in target :
76+ return os .environ .get ("CIBW_ARCHS" , "arm64 x86_64" )
77+
5978 return CIBW_ARCHS
6079
6180
0 commit comments