@@ -29,16 +29,28 @@ class MacOSWheelRepairer(RpathWheelRepairer):
2929 _origin_symbol = "@loader_path"
3030
3131 def get_library_rpath (self , artifact : Path ) -> list [str ]:
32- from delocate .tools import get_rpaths
33-
34- # Using the deprecated method here in order to support python 3.8
35- return list (get_rpaths (str (artifact )))
32+ import lief .MachO
33+
34+ rpaths = []
35+ fat_macho = lief .MachO .parse (artifact )
36+ for macho_it in range (fat_macho .size ):
37+ macho = fat_macho .at (macho_it )
38+ if not macho .has_rpath :
39+ continue
40+ for macho_rpath in macho .rpaths :
41+ rpaths .extend (macho_rpath .path )
42+ return rpaths
3643
3744 def patch_library_rpath (self , artifact : Path , rpaths : list [str ]) -> None :
38- from delocate .tools import _delete_rpaths , add_rpath
39-
40- original_rpaths = self .get_library_rpath (artifact )
41- _delete_rpaths (str (artifact ), set (original_rpaths ))
4245 final_rpaths = set (rpaths )
43- for rpath in final_rpaths :
44- add_rpath (str (artifact ), rpath )
46+ if final_rpaths :
47+ import lief .MachO
48+
49+ fat_macho = lief .MachO .parse (artifact )
50+ for macho_it in range (fat_macho .size ):
51+ macho = fat_macho .at (macho_it )
52+ macho .remove (lief .MachO .LoadCommand .TYPE .RPATH )
53+ for rpath in final_rpaths :
54+ macho_rpath = lief .MachO .RPathCommand .create (rpath )
55+ macho .add (macho_rpath )
56+ fat_macho .write (str (artifact ))
0 commit comments