Skip to content

Commit 19ef2f4

Browse files
committed
Fixed some syntax errors in the Windows wheel build.
1 parent 12a72aa commit 19ef2f4

3 files changed

Lines changed: 31 additions & 11 deletions

File tree

.github/workflows/python-app.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -565,16 +565,7 @@ jobs:
565565
python -m pip install --upgrade pip
566566
python -m pip install delvewheel
567567
568-
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: |
569-
# All DLL discovery and delvewheel invocation is handled inside
570-
# repair_windows_wheel.py to avoid YAML multi-line shell quoting
571-
# issues (nested if/else blocks at deep indentation caused the
572-
# script to be duplicated verbatim in the executed shell command).
573-
python "{project}/maintenance_scripts/repair_windows_wheel.py" "{dest_dir}" "{wheel}"
574-
575-
echo "=== delvewheel show repaired wheel ==="
576-
python -c "import glob, subprocess; wheels = sorted(glob.glob(r'{dest_dir}/*.whl')); assert wheels, 'No repaired wheel found'; [subprocess.run(['delvewheel', 'show', wheel], check=True) for wheel in wheels]"
577-
python -c "import glob, zipfile; wheels = sorted(glob.glob(r'{dest_dir}/*.whl')); assert wheels, 'No repaired wheel found'; found = {wheel: [name for name in zipfile.ZipFile(wheel).namelist() if name.startswith('sequenzo.libs/') and name.lower().endswith('.dll') and 'libomp140' in name.lower()] for wheel in wheels}; missing = [wheel for wheel, dlls in found.items() if not dlls]; assert not missing, 'Missing bundled libomp140*.dll in sequenzo.libs for: ' + ', '.join(missing); print('[OK] bundled OpenMP DLLs:', found)"
568+
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: python "{project}/maintenance_scripts/repair_windows_wheel.py" "{dest_dir}" "{wheel}"
578569

579570
# 注意:CIBW_BEFORE_BUILD(通用)在所有平台都提供了平台专用版本时
580571
# 永远不会执行(平台专用变体会覆盖通用变体),已移除死代码。

maintenance_scripts/repair_windows_wheel.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def main() -> int:
151151
if run_delvewheel(dest, wheel, omp_bin):
152152
repaired = sorted(dest.glob("*.whl"))[0]
153153
print(f"[repair] Repaired wheel (delvewheel): {repaired}")
154-
return 0
154+
return _finalize_repaired_wheel(repaired)
155155

156156
# --- Step 3: safety net — copy built wheel as-is ---
157157
print("[repair] delvewheel did not emit a wheel; copying built wheel as-is.")
@@ -162,6 +162,33 @@ def main() -> int:
162162
return 1
163163

164164
print(f"[repair] Repaired wheel (copied as-is): {target}")
165+
return _finalize_repaired_wheel(target)
166+
167+
168+
def _verify_bundled_openmp(wheel_path: Path) -> None:
169+
import zipfile
170+
171+
with zipfile.ZipFile(wheel_path) as zf:
172+
dlls = [
173+
name
174+
for name in zf.namelist()
175+
if name.startswith("sequenzo.libs/")
176+
and name.lower().endswith(".dll")
177+
and "libomp140" in name.lower()
178+
]
179+
if not dlls:
180+
print(
181+
f"[repair] ERROR: missing bundled libomp140*.dll in sequenzo.libs for {wheel_path}",
182+
file=sys.stderr,
183+
)
184+
raise SystemExit(1)
185+
print(f"[OK] bundled OpenMP DLLs: {dlls}")
186+
187+
188+
def _finalize_repaired_wheel(wheel_path: Path) -> int:
189+
print("=== delvewheel show repaired wheel ===")
190+
subprocess.run(["delvewheel", "show", str(wheel_path)], check=True)
191+
_verify_bundled_openmp(wheel_path)
165192
return 0
166193

167194

tests/test_build_release_boundaries.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ def test_macos_wheel_repair_fails_instead_of_copying_unrepaired_wheel():
2929
assert 'CIBW_TARGET_OSX_arm64: "11.0"' in source
3030
assert "build_macos_ci_libomp.sh" in source
3131
assert "repair_windows_wheel.py" in source
32+
assert 'CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: python "{project}/maintenance_scripts/repair_windows_wheel.py"' in source
3233
repair_script = (repo_root / "maintenance_scripts" / "repair_windows_wheel.py").read_text()
3334
assert "delvewheel did not emit a wheel; copying built wheel as-is" in repair_script
35+
assert "bundled OpenMP DLLs" in repair_script
3436
assert (repo_root / "maintenance_scripts" / "repair_windows_wheel.py").is_file()
3537
assert "exit 1" in source
3638
assert (repo_root / "maintenance_scripts" / "build_macos_ci_libomp.sh").is_file()

0 commit comments

Comments
 (0)