File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -69,10 +69,37 @@ def build_wheel(session: nox.Session) -> None:
6969 )
7070 elif is_macos :
7171 session .install ("delocate==0.10.4" )
72+
73+ # Remove per-architecture x86_64 dylibs from the wheel
74+ import zipfile
75+ import tempfile
76+
77+ wheel_path = os .path .join (temp_path , wheel_name )
78+ with tempfile .TemporaryDirectory () as tmpdir :
79+ tmp_whl_dir = Path (tmpdir ) / "wheel"
80+ tmp_whl_dir .mkdir ()
81+
82+ # Unzip wheel
83+ with zipfile .ZipFile (wheel_path , "r" ) as zip_ref :
84+ zip_ref .extractall (tmp_whl_dir )
85+
86+ # Remove the problematic metadata file
87+ for path in tmp_whl_dir .rglob ("*.dylibs" ):
88+ if "x86_64" in path .name :
89+ path .unlink ()
90+
91+ # Re-zip
92+ new_wheel_path = Path (temp_path ) / f"cleaned-{ wheel_name } "
93+ shutil .make_archive (
94+ str (new_wheel_path ).removesuffix (".whl" ), "zip" , tmp_whl_dir
95+ )
96+ new_wheel_path .rename (Path (new_wheel_path ).with_suffix (".whl" ))
97+
98+ # Now safely run delocate
7299 session .run (
73100 "delocate-wheel" ,
74101 "-v" ,
75- os . path . join ( temp_path , wheel_name ),
102+ str ( Path ( temp_path ) / new_wheel_path . name ),
76103 "-w" ,
77104 DIR / "wheelhouse" ,
78105 )
You can’t perform that action at this time.
0 commit comments