Skip to content

Commit 997f04d

Browse files
committed
Add wheel repair dependencies
Signed-off-by: Cristian Le <[email protected]>
1 parent 9712e0e commit 997f04d

File tree

5 files changed

+46
-7
lines changed

5 files changed

+46
-7
lines changed

pyproject.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,15 @@ disallow_untyped_defs = true
179179
disallow_incomplete_defs = true
180180

181181
[[tool.mypy.overrides]]
182-
module = ["numpy", "pathspec", "setuptools_scm", "hatch_fancy_pypi_readme", "virtualenv"]
182+
module = [
183+
"numpy",
184+
"pathspec",
185+
"setuptools_scm",
186+
"hatch_fancy_pypi_readme",
187+
"virtualenv",
188+
"auditwheel.*",
189+
"delvewheel.*",
190+
]
183191
ignore_missing_imports = true
184192

185193

src/scikit_build_core/build/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ def get_requires_for_build_sdist(
148148
return [
149149
*cmake_requires,
150150
*requires.dynamic_metadata(),
151+
*requires.other_dynamic_requires(),
151152
]
152153

153154

@@ -166,6 +167,7 @@ def get_requires_for_build_wheel(
166167
return [
167168
*cmake_requires,
168169
*requires.dynamic_metadata(),
170+
*requires.other_dynamic_requires(),
169171
]
170172

171173

@@ -184,4 +186,5 @@ def get_requires_for_build_editable(
184186
return [
185187
*cmake_requires,
186188
*requires.dynamic_metadata(),
189+
*requires.other_dynamic_requires(),
187190
]

src/scikit_build_core/builder/__main__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ def main() -> None:
3131

3232
if Path("pyproject.toml").is_file():
3333
req = GetRequires()
34-
all_req = [*req.cmake(), *req.ninja(), *req.dynamic_metadata()]
34+
all_req = [
35+
*req.cmake(),
36+
*req.ninja(),
37+
*req.dynamic_metadata(),
38+
*req.other_dynamic_requires(),
39+
]
3540
rich_print(f"{{bold.red}}Get Requires:{{normal}} {all_req!r}")
3641

3742
ip_program_search(color="magenta")

src/scikit_build_core/builder/get_requires.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import functools
55
import importlib.util
66
import os
7+
import platform
8+
import shutil
79
import sysconfig
810
from typing import TYPE_CHECKING, Literal
911

@@ -137,17 +139,34 @@ def ninja(self) -> Generator[str, None, None]:
137139
return
138140
yield f"ninja{ninja_verset}"
139141

140-
def dynamic_metadata(self) -> Generator[str, None, None]:
141-
if self.settings.fail:
142-
return
143-
142+
def other_dynamic_requires(self) -> Generator[str, None, None]:
144143
for build_require in self.settings.build.requires:
145144
yield build_require.format(
146145
**pyproject_format(
147146
settings=self.settings,
148147
)
149148
)
150149

150+
if self.settings.wheel.repair:
151+
platform_system = platform.system()
152+
if platform_system == "Linux":
153+
yield "auditwheel"
154+
patchelf_path = shutil.which("patchelf")
155+
if patchelf_path is None:
156+
yield "patchelf"
157+
elif platform_system == "Darwin":
158+
yield "delocate"
159+
elif platform_system == "Windows":
160+
yield "delvewheel"
161+
else:
162+
logger.warning(
163+
"Unknown platform {}. Cannot do wheel repairs.", platform_system
164+
)
165+
166+
def dynamic_metadata(self) -> Generator[str, None, None]:
167+
if self.settings.fail:
168+
return
169+
151170
for dynamic_metadata in self.settings.metadata.values():
152171
if "provider" in dynamic_metadata:
153172
config = dynamic_metadata.copy()

src/scikit_build_core/hatch/plugin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ def dependencies(self) -> list[str]:
111111

112112
# These are only injected if cmake is required
113113
cmake_requires = [*requires.cmake(), *requires.ninja()] if required else []
114-
return [*cmake_requires, *requires.dynamic_metadata()]
114+
return [
115+
*cmake_requires,
116+
*requires.dynamic_metadata(),
117+
*requires.other_dynamic_requires(),
118+
]
115119

116120
def initialize(self, version: str, build_data: dict[str, Any]) -> None:
117121
if version == "editable":

0 commit comments

Comments
 (0)