66
77from typing import TYPE_CHECKING
88
9- import delocate # noqa: F401
9+ from delocate . tools import _delete_rpaths , _get_rpaths , add_rpath
1010
11- from . import WheelRepairer
11+ from .._logging import logger
12+ from .rpath import RpathWheelRepairer
1213
1314if TYPE_CHECKING :
14- from .. file_api . model . codemodel import Target
15+ from pathlib import Path
1516
1617__all__ = ["MacOSWheelRepairer" ]
1718
@@ -20,13 +21,25 @@ def __dir__() -> list[str]:
2021 return __all__
2122
2223
23- class MacOSWheelRepairer (WheelRepairer ):
24+ class MacOSWheelRepairer (RpathWheelRepairer ):
2425 """
2526 Adjust the RPATH with @loader_path.
2627 """
2728
28- _platform = "Darwin"
29+ # TODO: Tighten multi-architecture assumption.
2930
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