Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
fix(windows): report paths, a RIFE that cannot start, provider command paths, and tests that assumed POSIX
jeonghwan.ko3477cb3d74d9
diff --git a/sprite_gen/qa/correction_loop.py b/sprite_gen/qa/correction_loop.pyindex 4dff371..04fcb05 100644--- a/sprite_gen/qa/correction_loop.py+++ b/sprite_gen/qa/correction_loop.py@@ -122,12 +122,13 @@ def run_loop(raise SystemExit("correction loop needs --provider-command, or use --dry-run for an inspect/score/hint demo")next_run_dir = out_dir / f"candidate-{attempt + 1}"prompt_file = attempt_dir / "correction-hints.txt"- command = provider_command.format(- prompt_file=str(prompt_file),- next_run_dir=str(next_run_dir),- attempt=attempt + 1,- )- completed = subprocess.run(shlex.split(command), capture_output=True, text=True)+ # The template is split first and each argument filled in after, so a substituted+ # path is never re-read as shell syntax: POSIX splitting would drop the backslashes+ # of a Windows path and break a path that holds a space or a quote.+ argv = [arg.format(prompt_file=str(prompt_file), next_run_dir=str(next_run_dir), attempt=attempt + 1)+ for arg in shlex.split(provider_command)]+ command = shlex.join(argv)+ completed = subprocess.run(argv, capture_output=True, text=True)atomic_write_text(attempt_dir / "provider.log",completed.stdout + ("\n--- stderr ---\n" + completed.stderr if completed.stderr else ""),diff --git a/sprite_gen/scene/render.py b/sprite_gen/scene/render.pyindex a8fa4bb..de0e16e 100644--- a/sprite_gen/scene/render.py+++ b/sprite_gen/scene/render.py@@ -22,7 +22,7 @@ from PIL import Imagefrom sprite_gen.scene.model import Scene, load_scenefrom sprite_gen.spec.assets import finite-from sprite_gen.spec.runio import LOCK_FILENAME, acquire_run_dir_lock, atomic_write_set, release_run_dir_lock+from sprite_gen.spec.runio import LOCK_FILENAME, acquire_run_dir_lock, atomic_write_set, relative_posix, release_run_dir_lockfrom sprite_gen.util.resample import resize_cell@@ -274,7 +274,8 @@ def _render_locked(scene, renderer, output, formats, settings, export_layers):"note": "Placement metadata references source files; copy referenced assets when moving this output."}report = {"kind": "sprite-gen-scene-render", "version": 1, "source_spec": str(scene.path),"source_fingerprints": scene.source_fingerprints, "frames": scene.frame_count,- "files": [str(p.relative_to(output)) for p in payloads] + ["placement.json", "scene.report.json"],+ # Report paths are manifest entries, so they use "/" on every OS.+ "files": [relative_posix(p, output) for p in payloads] + ["placement.json", "scene.report.json"],"encoding": encoding, "inspection": check}payloads[output / "placement.json"] = json.dumps(placement, indent=2)+"\n"payloads[output / "scene.report.json"] = json.dumps(report, indent=2)+"\n"diff --git a/sprite_gen/video/evidence.py b/sprite_gen/video/evidence.pyindex 40fef08..cf14bdf 100644--- a/sprite_gen/video/evidence.py+++ b/sprite_gen/video/evidence.py@@ -21,7 +21,8 @@ def engine_identity() -> dict[str, str]:root = Path(__file__).parentfiles = [*sorted(root.glob("*.py")), *sorted((root.parent / "frames").glob("*.py")),root.parent / "cli.py", root.parent / "util/resample.py", root.parent / "util/gif_utils.py"]- return {"implementation_sha256": digest(b"".join(str(p.relative_to(root.parent)).encode() + b"\0" + p.read_bytes() for p in files))}+ # Names hashed as POSIX paths, so one checkout has one fingerprint on every OS.+ return {"implementation_sha256": digest(b"".join(p.relative_to(root.parent).as_posix().encode() + b"\0" + p.read_bytes() for p in files))}def source_identity(files: list[Path], fps: float) -> dict[str, Any]:diff --git a/sprite_gen/video/rife.py b/sprite_gen/video/rife.pyindex 652683e..5543af3 100644--- a/sprite_gen/video/rife.py+++ b/sprite_gen/video/rife.py@@ -134,10 +134,15 @@ def _call(binary: Path, model: Path, a: Image.Image, b: Image.Image, t: float, tb.save(tmp / "b.png")out = tmp / "o.png"out.unlink(missing_ok=True)- proc = subprocess.run(- [str(binary), "-0", str(tmp / "a.png"), "-1", str(tmp / "b.png"), "-o", str(out), "-s", f"{t:.4f}", "-m", str(model)],- capture_output=True, text=True, timeout=CALL_TIMEOUT_SECONDS,- )+ try:+ proc = subprocess.run(+ [str(binary), "-0", str(tmp / "a.png"), "-1", str(tmp / "b.png"), "-o", str(out), "-s", f"{t:.4f}", "-m", str(model)],+ capture_output=True, text=True, timeout=CALL_TIMEOUT_SECONDS,+ )+ except OSError as exc:+ # A binary that is found but cannot be started (a damaged or wrong-platform build:+ # WinError 193 on Windows, ENOEXEC elsewhere) is a RIFE that fails, not a crash.+ raise RifeUnavailable(f"{binary.name} could not be started: {exc}") from excif proc.returncode != 0 or not out.is_file():raise RifeUnavailable(f"{binary.name} failed (exit {proc.returncode}): {(proc.stderr or proc.stdout).strip()[-300:]}")with Image.open(out) as im:diff --git a/tests/background/test_tile_cli.py b/tests/background/test_tile_cli.pyindex 4e690f2..f0aed05 100644--- a/tests/background/test_tile_cli.py+++ b/tests/background/test_tile_cli.py@@ -14,6 +14,8 @@ from PIL import Imagefrom sprite_gen.background import tilefrom sprite_gen.spec import runio+from conftest import symlink_or_skip+def invoke(source, out, *extra):return subprocess.run(@@ -75,7 +77,7 @@ def test_source_overwrite_and_aliases_are_refused(source, tmp_path, alias):elif alias in ("symlink", "hardlink"):out = tmp_path / "alias.png"if alias == "symlink":- out.symlink_to(source)+ symlink_or_skip(out, source)else:os.link(source, out)else:diff --git a/tests/conftest.py b/tests/conftest.pyindex 822e103..6c8e958 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -41,6 +41,22 @@ def run_script(name: str, *args: str) -> subprocess.CompletedProcess[str]:)+def symlink_or_skip(link: Path, target: Path) -> None:+ """Create ``link`` -> ``target``, skipping when the OS refuses symlinks.++ Windows only lets accounts with SeCreateSymbolicLinkPrivilege (or Developer+ Mode) create symlinks; otherwise the call fails with WinError 1314. The skip+ is limited to that creation failure, so a product that mishandles a link+ that *was* created still fails the test.+ """+ try:+ link.symlink_to(target)+ except OSError as exc:+ if sys.platform == "win32" and getattr(exc, "winerror", None) == 1314:+ pytest.skip("symlink creation needs SeCreateSymbolicLinkPrivilege or Developer Mode on Windows")+ raise++@pytest.fixturedef fixture_run_dir(tmp_path: Path) -> Path:"""A throwaway copy of the golden fixture run dir."""diff --git a/tests/effects/test_shadow.py b/tests/effects/test_shadow.pyindex 1bec4e8..199a276 100644--- a/tests/effects/test_shadow.py+++ b/tests/effects/test_shadow.py@@ -18,6 +18,8 @@ from sprite_gen.effects import shadowfrom sprite_gen.spec.assets import load_assetfrom sprite_gen.spec import runio+from conftest import symlink_or_skip+def _silhouette(size=(32, 48)):image = Image.new("RGBA", size)@@ -361,7 +363,7 @@ def test_invalid_target_is_rejected_without_mutating_destination(tmp_path, targeout_dir.mkdir()target = out_dir / "shadow.png"if target_kind == "symlink":- target.symlink_to(tmp_path / "unrelated.png")+ symlink_or_skip(target, tmp_path / "unrelated.png")else:target.mkdir()with pytest.raises(ValueError, match="regular file"):diff --git a/tests/frames/test_posix_manifest_paths.py b/tests/frames/test_posix_manifest_paths.pyindex f2b26c5..30ce3a2 100644--- a/tests/frames/test_posix_manifest_paths.py+++ b/tests/frames/test_posix_manifest_paths.py@@ -1,6 +1,7 @@# SPDX-License-Identifier: Apache-2.0"""Regression tests for OS-neutral paths in machine-readable manifests."""+import osfrom pathlib import Path, PureWindowsPathfrom sprite_gen.spec.runio import relative_posix@@ -20,4 +21,6 @@ def test_relative_posix_is_noop_for_posix_paths() -> None:root = Path("/sprite/run")frame = root / "frames" / "walk" / "frame-0.png"- assert relative_posix(frame, root) == str(frame.relative_to(root))+ assert relative_posix(frame, root) == "frames/walk/frame-0.png"+ if os.name != "nt": # on POSIX the OS's own spelling is already the manifest's+ assert relative_posix(frame, root) == str(frame.relative_to(root))diff --git a/tests/qa/test_inspect_score_loop.py b/tests/qa/test_inspect_score_loop.pyindex f7e136a..042f80a 100644--- a/tests/qa/test_inspect_score_loop.py+++ b/tests/qa/test_inspect_score_loop.py@@ -5,6 +5,8 @@ from __future__ import annotationsimport jsonfrom pathlib import Path+import shlex+import sysfrom conftest import run_script@@ -86,7 +88,8 @@ def test_correction_loop_min_attempts_forces_provider_then_converges(fixture_run"--out-dir", str(out_dir),"--max-passes", "3","--min-attempts", "2",- "--provider-command", f"python3 {provider} {fixture_run_dir} {{next_run_dir}}",+ # The template is POSIX shell syntax: literal paths are quoted so a Windows path keeps its backslashes.+ "--provider-command", shlex.join([sys.executable, str(provider), str(fixture_run_dir)]) + " {next_run_dir}",)assert result.returncode == 0, result.stdout + result.stderrloop_report = json.loads((out_dir / "correction-loop.report.json").read_text(encoding="utf-8"))diff --git a/tests/qa/test_motion.py b/tests/qa/test_motion.pyindex c40c64a..0f18ac4 100644--- a/tests/qa/test_motion.py+++ b/tests/qa/test_motion.py@@ -16,6 +16,8 @@ from PIL import Image, ImageDrawfrom sprite_gen.qa.motion import analyze_motionfrom sprite_gen.qa import motion+from conftest import symlink_or_skip+def sequence(xs=(24, 22, 20, 18, 16), *, durations=None, ys=None, two_feet=False):frames = []@@ -260,7 +262,7 @@ def test_output_cannot_overwrite_any_source_or_alias(tmp_path, capsys, target):source = descriptor(tmp_path)output = tmp_path / targetif target == "symlink.json":- output.symlink_to(source)+ symlink_or_skip(output, source)if target == "hardlink.json":os.link(source, output)before = file_bytes(tmp_path)diff --git a/tests/scene/test_inspect_scene.py b/tests/scene/test_inspect_scene.pyindex 6f45114..e447b9f 100644--- a/tests/scene/test_inspect_scene.py+++ b/tests/scene/test_inspect_scene.py@@ -14,6 +14,8 @@ from sprite_gen.scene.inspect_scene import inspect_scene, output_path, runfrom sprite_gen.scene.model import load_scenefrom sprite_gen.spec import runio+from conftest import symlink_or_skip+def frames_asset(tmp_path, name, images, duration=0.1):entries = []@@ -171,7 +173,7 @@ def test_run_refuses_reserved_names_scene_inputs_and_their_aliases(tmp_path, capspec = ramp_scene(tmp_path)out = tmp_path / targetif target == "spec-symlink.json":- out.symlink_to(spec)+ symlink_or_skip(out, spec)elif target == "asset-hardlink.png":os.link(tmp_path / "ramp-1.png", out)elif target == "a-directory":diff --git a/tests/scene/test_render.py b/tests/scene/test_render.pyindex 6c30245..0d1c007 100644--- a/tests/scene/test_render.py+++ b/tests/scene/test_render.py@@ -40,7 +40,8 @@ def write_scene(tmp_path, layers, *, width=16, height=12, fps=10, duration=0.5,def snapshot(directory):- return {str(p.relative_to(directory)): p.read_bytes() for p in Path(directory).rglob("*") if p.is_file()}+ # POSIX keys, like the report's file list, so the comparison holds on Windows too.+ return {p.relative_to(directory).as_posix(): p.read_bytes() for p in Path(directory).rglob("*") if p.is_file()}def test_anchor_velocity_camera_parallax_and_z_order_place_pixels(tmp_path):diff --git a/tests/video/test_one_step_cut.py b/tests/video/test_one_step_cut.pyindex 5ab7c23..51b00b5 100644--- a/tests/video/test_one_step_cut.py+++ b/tests/video/test_one_step_cut.py@@ -104,7 +104,10 @@ def _same_but_the_screen(a: Path, b: Path) -> None:frames = sorted(p.name for p in (a / "cycle").glob("*.png"))assert frames == sorted(p.name for p in (b / "cycle").glob("*.png"))assert all((a / "cycle" / f).read_bytes() == (b / "cycle" / f).read_bytes() for f in frames)- left, right = (json.loads((d / "loop.loop.report.json").read_text().replace(str(d), "@")) for d in (a, b))+ # The report is JSON text, so the run dir appears in it JSON-escaped: on Windows its+ # backslashes are doubled, and a raw str(d) would match nothing.+ left, right = (json.loads((d / "loop.loop.report.json").read_text(encoding="utf-8").replace(json.dumps(str(d))[1:-1], "@"))+ for d in (a, b))for report in (left, right):# The gait observation keeps a copy of the screen's record (sprite_gen/video/evidence.py): each# report's copy is its own record, and nothing else of the gait is set aside with it.diff --git a/tests/video/test_rife.py b/tests/video/test_rife.pyindex a7c7f0b..1031c7c 100644--- a/tests/video/test_rife.py+++ b/tests/video/test_rife.py@@ -19,7 +19,9 @@ from sprite_gen.video import rifedef _fake_binary(tmp_path: Path, with_model: bool = True) -> Path:- binary = tmp_path / "bin" / rife.BINARY+ # The platform's own file name (rife-ncnn-vulkan.exe on Windows): PATH lookup and the+ # install root only find the binary under that name.+ binary = tmp_path / "bin" / rife.installed_binary(Path(".")).namebinary.parent.mkdir(parents=True)binary.write_text("#!/bin/sh\nexit 0\n")binary.chmod(binary.stat().st_mode | stat.S_IXUSR)diff --git a/tests/video/test_rife_install.py b/tests/video/test_rife_install.pyindex 0a1ed5d..54c0e41 100644--- a/tests/video/test_rife_install.py+++ b/tests/video/test_rife_install.py@@ -9,6 +9,7 @@ import hashlibimport jsonimport osimport stat+import sysimport zipfilefrom pathlib import Path@@ -108,6 +109,9 @@ def test_another_dir_names_the_variable_that_points_the_engine_at_it(pinned, tmprife.locate()+# Windows runs the .exe it installs, never a shebang script, so a binary that starts and+# reports its own failure cannot be stood in for there; the next test covers Windows.[email protected](sys.platform == "win32", reason="a shebang script cannot stand in for rife-ncnn-vulkan.exe")def test_the_check_frame_fails_on_a_binary_that_does_not_run(pinned, tmp_path):rife_install.install(zip_path=pinned, platform=PLATFORM, run_check=False)target = tmp_path / "data" / "rife" / TOP@@ -116,6 +120,15 @@ def test_the_check_frame_fails_on_a_binary_that_does_not_run(pinned, tmp_path):rife_install.install(platform=PLATFORM)+def test_the_check_frame_fails_on_a_binary_that_cannot_be_started(pinned, tmp_path):+ """A damaged or wrong-platform build: the OS refuses to start it (ENOEXEC, WinError 193)."""+ rife_install.install(zip_path=pinned, platform=PLATFORM, run_check=False)+ target = tmp_path / "data" / "rife" / TOP+ (target / BINARY).write_bytes(b"\x00 not a program\n")+ with pytest.raises(SystemExit, match="check frame failed.*could not be started"):+ rife_install.install(platform=PLATFORM)++def test_a_platform_without_a_release_build_is_refused(monkeypatch):monkeypatch.setattr(rife, "platform_release", lambda: "")with pytest.raises(SystemExit, match="ships no build"):