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