Skip to content

Commit d43c53f

Browse files
committed
Add repo clean step before every build
1 parent 0506f8a commit d43c53f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

every_python/main.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,34 @@ def _get_configure_args(build_dir: Path, enable_jit: bool) -> list[str]:
135135
return args
136136

137137

138+
def _run_clean_repo(
139+
runner: CommandRunner,
140+
verbose: bool,
141+
progress: Progress,
142+
task: TaskID,
143+
) -> None:
144+
"""Run the clean repo step."""
145+
output = get_output()
146+
args = ["clean", "-fdx"]
147+
148+
if not (REPO_DIR / "Makefile").exists():
149+
return
150+
151+
if verbose:
152+
progress.stop()
153+
output.status(f"Running: git {' '.join(args)}")
154+
else:
155+
progress.update(task, description="Cleaning repo...")
156+
157+
result = runner.run_git(args, repo_dir=REPO_DIR)
158+
159+
if not result.success:
160+
if not verbose:
161+
progress.stop()
162+
output.error(f"Cleaning repo failed: {result.stderr if not verbose else ''}")
163+
raise typer.Exit(1)
164+
165+
138166
def _run_configure(
139167
runner: CommandRunner,
140168
build_dir: Path,
@@ -263,6 +291,9 @@ def build_python(commit: str, enable_jit: bool = False, verbose: bool = False) -
263291
output.error(f"Failed to checkout {commit}: {result.stderr}")
264292
raise typer.Exit(1)
265293

294+
# Clean repo
295+
_run_clean_repo(runner, verbose, progress, task)
296+
266297
# Configure
267298
_run_configure(runner, build_dir, enable_jit, verbose, progress, task)
268299

0 commit comments

Comments
 (0)