6
6
7
7
from typing import TYPE_CHECKING
8
8
9
- import delocate # noqa: F401
9
+ from delocate . tools import _delete_rpaths , _get_rpaths , add_rpath
10
10
11
- from . import WheelRepairer
11
+ from .._logging import logger
12
+ from .rpath import RpathWheelRepairer
12
13
13
14
if TYPE_CHECKING :
14
- from .. file_api . model . codemodel import Target
15
+ from pathlib import Path
15
16
16
17
__all__ = ["MacOSWheelRepairer" ]
17
18
@@ -20,13 +21,25 @@ def __dir__() -> list[str]:
20
21
return __all__
21
22
22
23
23
- class MacOSWheelRepairer (WheelRepairer ):
24
+ class MacOSWheelRepairer (RpathWheelRepairer ):
24
25
"""
25
26
Adjust the RPATH with @loader_path.
26
27
"""
27
28
28
- _platform = "Darwin"
29
+ # TODO: Tighten multi-architecture assumption.
29
30
30
- def patch_target (self , target : Target ) -> None :
31
- # TODO: Implement patching
32
- pass
31
+ _platform = "Darwin"
32
+ _origin_symbol = "@loader_path"
33
+
34
+ def get_library_rpath (self , artifact : Path ) -> list [str ]:
35
+ arch_rpaths = _get_rpaths (artifact )
36
+ if len (arch_rpaths ) > 1 :
37
+ logger .warning ("Multiple architecture rpath parsing not implemented" )
38
+ return [path for arch in arch_rpaths for path in arch_rpaths [arch ]]
39
+
40
+ def patch_library_rpath (self , artifact : Path , rpaths : list [str ]) -> None :
41
+ original_rpaths = self .get_library_rpath (artifact )
42
+ _delete_rpaths (str (artifact ), set (original_rpaths ))
43
+ final_rpaths = set (rpaths )
44
+ for rpath in final_rpaths :
45
+ add_rpath (str (artifact ), rpath )
0 commit comments