1
1
# -*- coding: utf-8 -*-
2
2
import argparse
3
+ import re
3
4
import shutil
4
5
import subprocess
5
6
import sys
@@ -43,7 +44,7 @@ def main():
43
44
subprocess .run (["auditwheel" , "repair" , "-w" , str (tmpdir ), str (file )], check = True , stdout = subprocess .PIPE )
44
45
elif os_ == "macos" :
45
46
subprocess .run (
46
- ["delocate-wheel" , "--require-archs" , "x86_64" , "-w" , str (tmpdir ), str (file )],
47
+ ["delocate-wheel" , "--require-archs" , "x86_64,arm64 " , "-w" , str (tmpdir ), str (file )],
47
48
check = True ,
48
49
stdout = subprocess .PIPE ,
49
50
)
@@ -54,11 +55,34 @@ def main():
54
55
assert len (files ) == 1 , files
55
56
file = files [0 ]
56
57
58
+ # we need to handle macOS universal2 & arm64 here for now, let's use additional_platforms for this.
59
+ additional_platforms = []
60
+ if os_ == "macos" :
61
+ # first, get the target macOS deployment target from the wheel
62
+ match = re .match (r"^.*-macosx_(\d+)_(\d+)_x86_64\.whl$" , file .name )
63
+ assert match is not None
64
+ target = tuple (map (int , match .groups ()))
65
+
66
+ # let's add universal2 platform for this wheel.
67
+ additional_platforms = ["macosx_{}_{}_universal2" .format (* target )]
68
+
69
+ # given pip support for universal2 was added after arm64 introduction
70
+ # let's also add arm64 platform.
71
+ arm64_target = target
72
+ if arm64_target < (11 , 0 ):
73
+ arm64_target = (11 , 0 )
74
+ additional_platforms .append ("macosx_{}_{}_arm64" .format (* arm64_target ))
75
+
76
+ if target < (11 , 0 ):
77
+ # They're were also issues with pip not picking up some universal2 wheels, tag twice
78
+ additional_platforms .append ("macosx_11_0_universal2" )
79
+
57
80
# make this a py2.py3 wheel
58
81
convert_to_generic_platform_wheel (
59
82
str (file ),
60
83
out_dir = str (wheelhouse ),
61
84
py2_py3 = True ,
85
+ additional_platforms = additional_platforms ,
62
86
)
63
87
64
88
0 commit comments