Improve artifact detection logic in build script to prioritize executable files and directories, enhancing robustness and user feedback.
This commit is contained in:
@@ -157,13 +157,34 @@ def build(build: bool = True, copy: bool = True, test: bool = False, dest: str |
|
|||||||
if not artifact_dir.exists():
|
if not artifact_dir.exists():
|
||||||
artifact_dir = project_root / "dist"
|
artifact_dir = project_root / "dist"
|
||||||
|
|
||||||
# Look for a matching artifact
|
# Look for a matching artifact. Prefer exe files named Uploader*.exe,
|
||||||
candidates = list(artifact_dir.glob("Uploader*")) + list(artifact_dir.glob("*.exe"))
|
# then any .exe, then directories named Uploader* (onedir builds).
|
||||||
if not candidates:
|
# Exclude obvious non-artifacts like log files.
|
||||||
print(f"No build artifact found in {artifact_dir}, skipping copy")
|
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
|
return
|
||||||
|
|
||||||
artifact = candidates[0]
|
artifact = valid[0]
|
||||||
|
|
||||||
dest_path = Path(dest) if dest else default_dest
|
dest_path = Path(dest) if dest else default_dest
|
||||||
dest_path.mkdir(parents=True, exist_ok=True)
|
dest_path.mkdir(parents=True, exist_ok=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user