diff --git a/scripts/windows_build_python_instance.py b/scripts/windows_build_python_instance.py index 2c8241e0..2ef8ae78 100644 --- a/scripts/windows_build_python_instance.py +++ b/scripts/windows_build_python_instance.py @@ -222,7 +222,8 @@ def build_tarball(self) -> None: ] cmd += ["-xr!" + pattern.replace("/", "\\") for pattern in ARCHIVE_EXCLUDES] return_status: int = self.echo_check_call(cmd) - if return_status == 0: + # 1 is a warning, such as a file another process holds open. + if return_status in (0, 1): return if out_zip.exists(): diff --git a/tests/test_windows_wheel_builder.py b/tests/test_windows_wheel_builder.py index d99541be..b8baf1c3 100644 --- a/tests/test_windows_wheel_builder.py +++ b/tests/test_windows_wheel_builder.py @@ -210,7 +210,7 @@ def test_repaired_wheel_replaces_the_input_in_place( def _run_build_tarball( - windows_builder: WindowsBuildPythonInstance, tmp_path: Path + windows_builder: WindowsBuildPythonInstance, tmp_path: Path, status: int = 0 ) -> list[str]: """Drive ``build_tarball`` down the 7-Zip branch and return the command.""" windows_builder.ipp_dir = tmp_path / "IPP" @@ -219,7 +219,7 @@ def _run_build_tarball( def fake_call(cmd: Sequence[object], *args: object, **kwargs: object) -> int: captured["cmd"] = [str(c) for c in cmd] - return 0 + return status with ( patch("windows_build_python_instance.shutil.which", return_value="/fake/7z"), @@ -272,6 +272,14 @@ def test_seven_zip_starts_a_new_archive( assert not stale.exists() +def test_seven_zip_warnings_keep_its_archive( + tmp_path: Path, windows_builder: WindowsBuildPythonInstance +) -> None: + """Exit code 1 (e.g. a locked log file) must not start the zip fallback.""" + _run_build_tarball(windows_builder, tmp_path, status=1) + assert not (windows_builder.build_dir_root / "ITKPythonBuilds-windows.zip").exists() + + def test_zip_fallback_archives_the_seven_zip_roots( tmp_path: Path, windows_builder: WindowsBuildPythonInstance ) -> None: