Skip to content

Commit 91e57bc

Browse files
committed
Make the wheel repairing configurable
Signed-off-by: Cristian Le <[email protected]>
1 parent 150cd67 commit 91e57bc

File tree

7 files changed

+70
-4
lines changed

7 files changed

+70
-4
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ wheel.build-tag = ""
223223
# Do automatic repairs of the compiled binaries and libraries.
224224
wheel.repair.enable = false
225225

226+
# Patch the dynamic links to libraries installed in the current wheel.
227+
wheel.repair.in-wheel = true
228+
229+
# Patch the dynamic links to libraries in other wheels.
230+
wheel.repair.cross-wheel = false
231+
226232
# If CMake is less than this value, backport a copy of FindPython.
227233
backport.find-python = "3.26.1"
228234

docs/reference/configs.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,19 @@ print(mk_skbuild_docs())
576576

577577
## wheel.repair
578578

579+
```{eval-rst}
580+
.. confval:: wheel.repair.cross-wheel
581+
:type: ``bool``
582+
:default: false
583+
584+
Patch the dynamic links to libraries in other wheels.
585+
586+
.. note::
587+
This may result in incompatible wheels. Use this only if the
588+
wheels are strongly linked to each other and strict manylinux compliance is
589+
not required.
590+
```
591+
579592
```{eval-rst}
580593
.. confval:: wheel.repair.enable
581594
:type: ``bool``
@@ -587,4 +600,12 @@ print(mk_skbuild_docs())
587600
This is an experimental feature gated by :confval:`experimental`
588601
```
589602

603+
```{eval-rst}
604+
.. confval:: wheel.repair.in-wheel
605+
:type: ``bool``
606+
:default: true
607+
608+
Patch the dynamic links to libraries installed in the current wheel.
609+
```
610+
590611
<!-- [[[end]]] -->

src/scikit_build_core/repair_wheel/rpath.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,14 @@ def patch_target(self, target: Target) -> None:
164164
for install_path in target_install_paths:
165165
target_path = self.install_dir / install_path
166166
artifact_path = target_path / artifact.path.name
167-
dependency_rpaths = self.get_dependency_rpaths(target, install_path)
168-
package_rpaths = self.get_package_rpaths(target, install_path)
167+
if self.settings.wheel.repair.in_wheel:
168+
dependency_rpaths = self.get_dependency_rpaths(target, install_path)
169+
else:
170+
dependency_rpaths = []
171+
if self.settings.wheel.repair.cross_wheel:
172+
package_rpaths = self.get_package_rpaths(target, install_path)
173+
else:
174+
package_rpaths = []
169175
existing_rpaths = self.get_existing_rpaths(artifact_path)
170176
logger.debug(
171177
"Patching rpaths for artifact {artifact}\n"

src/scikit_build_core/repair_wheel/windows.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,15 @@ def get_package_dll(self, target: Target) -> list[Path]:
210210

211211
def patch_target(self, target: Target) -> None:
212212
# Here we just gather all dll paths needed for each target
213-
package_dlls = self.get_package_dll(target)
214-
dependency_dlls = self.get_dependency_dll(target)
213+
if self.settings.wheel.repair.in_wheel:
214+
dependency_dlls = self.get_dependency_dll(target)
215+
else:
216+
dependency_dlls = []
217+
if self.settings.wheel.repair.cross_wheel:
218+
package_dlls = self.get_package_dll(target)
219+
else:
220+
package_dlls = []
221+
215222
if not package_dlls and not dependency_dlls:
216223
logger.warning(
217224
"No dll files found for target {target}",

src/scikit_build_core/resources/scikit-build.schema.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,16 @@
248248
"type": "boolean",
249249
"default": false,
250250
"description": "Do automatic repairs of the compiled binaries and libraries."
251+
},
252+
"in-wheel": {
253+
"type": "boolean",
254+
"default": true,
255+
"description": "Patch the dynamic links to libraries installed in the current wheel."
256+
},
257+
"cross-wheel": {
258+
"type": "boolean",
259+
"default": false,
260+
"description": "Patch the dynamic links to libraries in other wheels."
251261
}
252262
},
253263
"description": "Wheel repair options"

src/scikit_build_core/settings/skbuild_model.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,21 @@ class WheelRepair:
232232
This is an experimental feature gated by :confval:`experimental`
233233
"""
234234

235+
in_wheel: bool = True
236+
"""
237+
Patch the dynamic links to libraries installed in the current wheel.
238+
"""
239+
240+
cross_wheel: bool = False
241+
"""
242+
Patch the dynamic links to libraries in other wheels.
243+
244+
.. note::
245+
This may result in incompatible wheels. Use this only if the
246+
wheels are strongly linked to each other and strict manylinux compliance is
247+
not required.
248+
"""
249+
235250

236251
@dataclasses.dataclass
237252
class WheelSettings:

tests/packages/repair_wheel/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ dependencies = ["base_project"]
1111
build.requires = ["base_project @ {root:uri}/extern"]
1212
wheel.install-dir = "repair_wheel"
1313
wheel.repair.enable = true
14+
wheel.repair.cross-wheel = true
1415
experimental = true
1516

1617
[project.scripts]

0 commit comments

Comments
 (0)