Skip to content

Commit 928e504

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

File tree

5 files changed

+26
-22
lines changed

5 files changed

+26
-22
lines changed

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ test-hatchling = [
6969
test-meta = [
7070
"hatch-fancy-pypi-readme>=22.3",
7171
"setuptools-scm",
72-
"lief; platform_system=='Linux'",
73-
"delocate; platform_system=='Darwin'",
72+
"lief; platform_system=='Linux' or platform_system=='Darwin'",
7473
]
7574
test-numpy = [
7675
"numpy; python_version<'3.14' and platform_python_implementation!='PyPy' and (platform_system != 'Windows' or platform_machine != 'ARM64')",
@@ -199,7 +198,6 @@ module = [
199198
"setuptools_scm",
200199
"hatch_fancy_pypi_readme",
201200
"virtualenv",
202-
"delocate.*",
203201
"lief.*",
204202
]
205203
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: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,28 @@ class MacOSWheelRepairer(RpathWheelRepairer):
3131
_origin_symbol = "@loader_path"
3232

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

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

tests/conftest.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,8 @@ def pep518_wheelhouse(tmp_path_factory: pytest.TempPathFactory) -> Path:
5757
"virtualenv",
5858
"wheel",
5959
]
60-
if platform.system() == "Linux":
60+
if platform.system() in ("Linux", "Darwin"):
6161
packages.append("lief")
62-
if platform.system() == "Darwin":
63-
packages.append("delocate")
6462

6563
if importlib.util.find_spec("cmake") is not None:
6664
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)