11# -*- coding: utf-8 -*-
22import argparse
3+ import re
34import shutil
45import subprocess
56import sys
@@ -43,7 +44,7 @@ def main():
4344 subprocess .run (["auditwheel" , "repair" , "-w" , str (tmpdir ), str (file )], check = True , stdout = subprocess .PIPE )
4445 elif os_ == "macos" :
4546 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 )],
4748 check = True ,
4849 stdout = subprocess .PIPE ,
4950 )
@@ -54,11 +55,34 @@ def main():
5455 assert len (files ) == 1 , files
5556 file = files [0 ]
5657
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+
5780 # make this a py2.py3 wheel
5881 convert_to_generic_platform_wheel (
5982 str (file ),
6083 out_dir = str (wheelhouse ),
6184 py2_py3 = True ,
85+ additional_platforms = additional_platforms ,
6286 )
6387
6488
0 commit comments