Skip to content

Commit f8b1de7

Browse files
committed
Use lief for macos as well
Signed-off-by: Cristian Le <[email protected]>
1 parent 9d740e6 commit f8b1de7

File tree

5 files changed

+27
-22
lines changed

5 files changed

+27
-22
lines changed

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ test-hatchling = [
6868
test-meta = [
6969
"hatch-fancy-pypi-readme>=22.3",
7070
"setuptools-scm",
71-
"lief; platform_system=='Linux'",
72-
"delocate; platform_system=='Darwin'",
71+
"lief; platform_system=='Linux' or platform_system=='Darwin'",
7372
]
7473
test-numpy = [
7574
"numpy; python_version<'3.14' and platform_python_implementation!='PyPy' and (platform_system != 'Windows' or platform_machine != 'ARM64')",
@@ -191,7 +190,6 @@ module = [
191190
"setuptools_scm",
192191
"hatch_fancy_pypi_readme",
193192
"virtualenv",
194-
"delocate.*",
195193
"lief.*",
196194
]
197195
ignore_missing_imports = true

src/scikit_build_core/builder/get_requires.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,8 @@ def other_dynamic_requires(self) -> Generator[str, None, None]:
148148

149149
if self.settings.wheel.repair.enable:
150150
platform_system = platform.system()
151-
if platform_system == "Linux":
151+
if platform_system in ("Linux", "Darwin"):
152152
yield "lief"
153-
elif platform_system == "Darwin":
154-
yield "delocate"
155153

156154
def dynamic_metadata(self) -> Generator[str, None, None]:
157155
if self.settings.fail:

src/scikit_build_core/repair_wheel/darwin.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,29 @@ class MacOSWheelRepairer(RpathWheelRepairer):
2929
_origin_symbol = "@loader_path"
3030

3131
def get_library_rpath(self, artifact: Path) -> list[str]:
32-
from delocate.tools import get_rpaths
33-
34-
# Using the deprecated method here in order to support python 3.8
35-
return list(get_rpaths(str(artifact)))
32+
import lief.MachO
33+
34+
rpaths = []
35+
fat_macho = lief.MachO.parse(artifact)
36+
for macho_it in range(fat_macho.size):
37+
macho = fat_macho.at(macho_it)
38+
if not macho.has_rpath:
39+
continue
40+
for macho_rpath in macho.rpaths:
41+
rpaths.extend(macho_rpath.path)
42+
return rpaths
3643

3744
def patch_library_rpath(self, artifact: Path, rpaths: list[str]) -> None:
38-
from delocate.tools import _delete_rpaths, add_rpath
39-
40-
original_rpaths = self.get_library_rpath(artifact)
41-
_delete_rpaths(str(artifact), set(original_rpaths))
4245
final_rpaths = set(rpaths)
43-
for rpath in final_rpaths:
44-
add_rpath(str(artifact), rpath)
46+
if final_rpaths:
47+
import lief.MachO
48+
49+
fat_macho = lief.MachO.parse(artifact)
50+
for macho_it in range(fat_macho.size):
51+
macho = fat_macho.at(macho_it)
52+
macho.remove(lief.MachO.LoadCommand.TYPE.RPATH)
53+
for rpath in final_rpaths:
54+
macho_rpath = lief.MachO.RPathCommand.create(rpath)
55+
macho.extend(macho_rpath, macho_rpath.size)
56+
macho.add(macho_rpath)
57+
fat_macho.write(str(artifact))

tests/conftest.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ def pep518_wheelhouse(tmp_path_factory: pytest.TempPathFactory) -> Path:
5454
"virtualenv",
5555
"wheel",
5656
]
57-
if platform.system() == "Linux":
57+
if platform.system() in ("Linux", "Darwin"):
5858
packages.append("lief")
59-
if platform.system() == "Darwin":
60-
packages.append("delocate")
6159

6260
if importlib.util.find_spec("cmake") is not None:
6361
packages.append("cmake")

tests/test_repair_wheel.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@ def test_full_build(
4545

4646
if not with_isolation:
4747
isolated.install("scikit-build-core")
48-
if platform.system() == "Linux":
48+
if platform.system() in ("Linux", "Darwin"):
4949
isolated.install("lief")
50-
if platform.system() == "Darwin":
51-
isolated.install("delocate")
5250
isolated.install("./extern", isolated=with_isolation)
5351

5452
if backend == "pip":

0 commit comments

Comments
 (0)