Skip to content

Commit a9cd9db

Browse files
committed
Implement macos
Signed-off-by: Cristian Le <git@lecris.dev>
1 parent 331f0f9 commit a9cd9db

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/scikit_build_core/repair_wheel/darwin.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66

77
from 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

1314
if 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

Comments
 (0)