Skip to content

Commit 246b16f

Browse files
committed
Implement macos
Signed-off-by: Cristian Le <git@lecris.dev>
1 parent 593c089 commit 246b16f

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

src/scikit_build_core/repair_wheel/darwin.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
from typing import TYPE_CHECKING
88

9-
from . import WheelRepairer
9+
from .._logging import logger
10+
from .rpath import RpathWheelRepairer
1011

1112
if TYPE_CHECKING:
12-
from ..file_api.model.codemodel import Target
13+
from pathlib import Path
1314

1415
__all__ = ["MacOSWheelRepairer"]
1516

@@ -18,13 +19,29 @@ def __dir__() -> list[str]:
1819
return __all__
1920

2021

21-
class MacOSWheelRepairer(WheelRepairer):
22+
class MacOSWheelRepairer(RpathWheelRepairer):
2223
"""
2324
Adjust the RPATH with @loader_path.
2425
"""
2526

27+
# TODO: Tighten multi-architecture assumption.
28+
2629
_platform = "Darwin"
30+
_origin_symbol = "@loader_path"
31+
32+
def get_library_rpath(self, artifact: Path) -> list[str]:
33+
from delocate.tools import _get_rpaths
34+
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+
from delocate.tools import _delete_rpaths, add_rpath
2742

28-
def patch_target(self, target: Target) -> None:
29-
# TODO: Implement patching
30-
pass
43+
original_rpaths = self.get_library_rpath(artifact)
44+
_delete_rpaths(str(artifact), set(original_rpaths))
45+
final_rpaths = set(rpaths)
46+
for rpath in final_rpaths:
47+
add_rpath(str(artifact), rpath)

0 commit comments

Comments
 (0)