Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/windows_build_python_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ def build_tarball(self) -> None:
]
cmd += ["-xr!" + pattern.replace("/", "\\") for pattern in ARCHIVE_EXCLUDES]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should-fix: include files held open for writing, which fixes the run2.log case without accepting other warnings.

Suggested change
cmd += ["-xr!" + pattern.replace("/", "\\") for pattern in ARCHIVE_EXCLUDES]
cmd += ["-ssw"]
cmd += ["-xr!" + pattern.replace("/", "\\") for pattern in ARCHIVE_EXCLUDES]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be explicit about my preference: I'd rather take -ssw than accept exit code 1. -ssw fixes the open-log case directly, and keeping == 0 means any other warning (a locked build file, a missing root) still reaches the fallback rather than publishing an incomplete cache.

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):
Comment on lines +225 to +226

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should-fix: with -ssw, exit 1 means something else went wrong (an unreadable file, access denied, a missing root), so it should still go to the fallback.

Suggested change
# 1 is a warning, such as a file another process holds open.
if return_status in (0, 1):
if return_status == 0:

If you'd still rather keep a warned archive, print the skipped paths from the captured output first, so the log says which files are missing (see the review body).

return

if out_zip.exists():
Expand Down
12 changes: 10 additions & 2 deletions tests/test_windows_wheel_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should-fix: the fake never writes the archive, so the test below can't tell "kept" from "never written". Have it write a marker so the test can check that the archive survives:

Suggested change
return status
(windows_builder.build_dir_root / "ITKPythonBuilds-windows.zip").write_bytes(b"7z")
return status


with (
patch("windows_build_python_instance.shutil.which", return_value="/fake/7z"),
Expand Down Expand Up @@ -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()
Comment on lines +275 to +280

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should-fix: as written, this asserts the archive does not exist, the opposite of its name. With the marker above, assert the bytes survive at status 0. Add a test that status 1 and 2 (or 1 alone, if you take the -ssw route) still run the zip fallback, since that boundary is what this PR moves. If -ssw goes in, assert it is in the command next to test_seven_zip_command_carries_no_recursive_flag.



def test_zip_fallback_archives_the_seven_zip_roots(
tmp_path: Path, windows_builder: WindowsBuildPythonInstance
) -> None:
Expand Down
Loading