77import dataclasses
88from typing import TYPE_CHECKING
99
10- from .base import WheelRepairer
10+ from .._logging import logger
11+ from .rpath import RpathWheelRepairer
1112
1213if TYPE_CHECKING :
13- from .. file_api . model . codemodel import Target
14+ from pathlib import Path
1415
1516__all__ = ["MacOSWheelRepairer" ]
1617
@@ -20,13 +21,29 @@ def __dir__() -> list[str]:
2021
2122
2223@dataclasses .dataclass
23- class MacOSWheelRepairer (WheelRepairer ):
24+ class MacOSWheelRepairer (RpathWheelRepairer ):
2425 """
2526 Adjust the RPATH with @loader_path.
2627 """
2728
29+ # TODO: Tighten multi-architecture assumption.
30+
2831 _platform = "Darwin"
32+ _origin_symbol = "@loader_path"
33+
34+ def get_library_rpath (self , artifact : Path ) -> list [str ]:
35+ from delocate .tools import _get_rpaths
36+
37+ arch_rpaths = _get_rpaths (artifact )
38+ if len (arch_rpaths ) > 1 :
39+ logger .warning ("Multiple architecture rpath parsing not implemented" )
40+ return [path for arch in arch_rpaths for path in arch_rpaths [arch ]]
41+
42+ def patch_library_rpath (self , artifact : Path , rpaths : list [str ]) -> None :
43+ from delocate .tools import _delete_rpaths , add_rpath
2944
30- def patch_target (self , target : Target ) -> None :
31- # TODO: Implement patching
32- pass
45+ original_rpaths = self .get_library_rpath (artifact )
46+ _delete_rpaths (str (artifact ), set (original_rpaths ))
47+ final_rpaths = set (rpaths )
48+ for rpath in final_rpaths :
49+ add_rpath (str (artifact ), rpath )
0 commit comments