diff --git a/build.py b/build.py index d70b70d..6cd9009 100644 --- a/build.py +++ b/build.py @@ -157,13 +157,34 @@ def build(build: bool = True, copy: bool = True, test: bool = False, dest: str | if not artifact_dir.exists(): artifact_dir = project_root / "dist" - # Look for a matching artifact - candidates = list(artifact_dir.glob("Uploader*")) + list(artifact_dir.glob("*.exe")) - if not candidates: - print(f"No build artifact found in {artifact_dir}, skipping copy") + # Look for a matching artifact. Prefer exe files named Uploader*.exe, + # then any .exe, then directories named Uploader* (onedir builds). + # Exclude obvious non-artifacts like log files. + candidates = [] + # Uploader*.exe (preferred) + candidates.extend(sorted(artifact_dir.glob("Uploader*.exe"))) + # any .exe + candidates.extend(sorted(artifact_dir.glob("*.exe"))) + # onedir: directories starting with Uploader + candidates.extend([p for p in sorted(artifact_dir.glob("Uploader*")) if p.is_dir()]) + + # Filter out files that look like logs or non-executables + def is_valid_artifact(p: Path) -> bool: + if not p.exists(): + return False + if p.is_file(): + # require .exe for files (Windows builds) + return p.suffix.lower() == ".exe" + if p.is_dir(): + return True + return False + + valid = [p for p in candidates if is_valid_artifact(p)] + if not valid: + print(f"No build artifact (.exe or Uploader directory) found in {artifact_dir}, skipping copy") return - artifact = candidates[0] + artifact = valid[0] dest_path = Path(dest) if dest else default_dest dest_path.mkdir(parents=True, exist_ok=True)