Skip to content

Commit 66d45de

Browse files
authored
repair-wheel-command docs and error message improvements (pypa#2058)
* Fix bug in docs for running abi3audit in repair-wheel-command on windows * Better error message for misconfigured repair-wheel-command
1 parent eaa8616 commit 66d45de

File tree

5 files changed

+34
-3
lines changed

5 files changed

+34
-3
lines changed

cibuildwheel/errors.py

+18
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,21 @@ class OCIEngineTooOldError(FatalError):
6767
def __init__(self, message: str) -> None:
6868
super().__init__(message)
6969
self.return_code = 7
70+
71+
72+
class RepairStepProducedNoWheelError(FatalError):
73+
def __init__(self) -> None:
74+
message = textwrap.dedent(
75+
"""
76+
Build failed because the repair step completed successfully but
77+
did not produce a wheel.
78+
79+
Your `repair-wheel-command` is expected to place the repaired
80+
wheel in the {dest_dir} directory. See the documentation for
81+
example configurations:
82+
83+
https://cibuildwheel.pypa.io/en/stable/options/#repair-wheel-command
84+
"""
85+
)
86+
super().__init__(message)
87+
self.return_code = 8

cibuildwheel/linux.py

+3
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,9 @@ def build_in_container(
326326

327327
repaired_wheels = container.glob(repaired_wheel_dir, "*.whl")
328328

329+
if not repaired_wheels:
330+
raise errors.RepairStepProducedNoWheelError()
331+
329332
for repaired_wheel in repaired_wheels:
330333
if repaired_wheel.name in {wheel.name for wheel in built_wheels}:
331334
raise errors.AlreadyBuiltWheelError(repaired_wheel.name)

cibuildwheel/macos.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,10 @@ def build(options: Options, tmp_path: Path) -> None:
551551
else:
552552
shutil.move(str(built_wheel), repaired_wheel_dir)
553553

554-
repaired_wheel = next(repaired_wheel_dir.glob("*.whl"))
554+
try:
555+
repaired_wheel = next(repaired_wheel_dir.glob("*.whl"))
556+
except StopIteration:
557+
raise errors.RepairStepProducedNoWheelError() from None
555558

556559
if repaired_wheel.name in {wheel.name for wheel in built_wheels}:
557560
raise errors.AlreadyBuiltWheelError(repaired_wheel.name)

cibuildwheel/windows.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,10 @@ def build(options: Options, tmp_path: Path) -> None:
490490
else:
491491
shutil.move(str(built_wheel), repaired_wheel_dir)
492492

493-
repaired_wheel = next(repaired_wheel_dir.glob("*.whl"))
493+
try:
494+
repaired_wheel = next(repaired_wheel_dir.glob("*.whl"))
495+
except StopIteration:
496+
raise errors.RepairStepProducedNoWheelError() from None
494497

495498
if repaired_wheel.name in {wheel.name for wheel in built_wheels}:
496499
raise errors.AlreadyBuiltWheelError(repaired_wheel.name)

docs/options.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,7 @@ Platform-specific environment variables are also available:<br/>
11201120
delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} &&
11211121
pipx run abi3audit --strict --report {wheel}
11221122
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >
1123+
copy {wheel} {dest_dir} &&
11231124
pipx run abi3audit --strict --report {wheel}
11241125
```
11251126

@@ -1158,7 +1159,10 @@ Platform-specific environment variables are also available:<br/>
11581159
"pipx run abi3audit --strict --report {wheel}",
11591160
]
11601161
[tool.cibuildwheel.windows]
1161-
repair-wheel-command = "pipx run abi3audit --strict --report {wheel}"
1162+
repair-wheel-command = [
1163+
"copy {wheel} {dest_dir}",
1164+
"pipx run abi3audit --strict --report {wheel}",
1165+
]
11621166
```
11631167

11641168
In configuration mode, you can use an inline array, and the items will be joined with `&&`.

0 commit comments

Comments
 (0)