Skip to content

Commit d4c8389

Browse files
Enhance precheck setup and Docker handling
- Updated the setup process to install the cf-precheck Python package instead of pulling a Docker image, improving installation flexibility. - Added version display for the installed cf-precheck package to provide user feedback. - Implemented a check for Docker image updates before running the precheck command, ensuring the latest image is used. - Streamlined argument handling for the precheck command, maintaining support for magic DRC and skip checks options.
1 parent 598bde7 commit d4c8389

1 file changed

Lines changed: 47 additions & 24 deletions

File tree

chipfoundry_cli/main.py

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,24 +2763,30 @@ def maybe_abort_no_space(err, step_label):
27632763
step_num = 8 if not only_mode else ""
27642764
console.print(f"\n[bold]Step {step_num}:[/bold] Installing precheck...")
27652765

2766-
if shutil.which('docker') is None:
2767-
had_errors = True
2768-
console.print("[red]✗[/red] Docker not found. Install Docker Desktop to pull the precheck image.")
2769-
elif dry_run:
2770-
console.print("[dim]Would pull chipfoundry/mpw_precheck:latest[/dim]")
2766+
if dry_run:
2767+
console.print("[dim]Would install/upgrade cf-precheck Python package[/dim]")
27712768
else:
27722769
try:
2773-
console.print("[cyan]Pulling precheck Docker image...[/cyan]")
2770+
console.print("[cyan]Installing cf-precheck...[/cyan]")
27742771
subprocess.run(
2775-
['docker', 'pull', 'chipfoundry/mpw_precheck:latest'],
2772+
[sys.executable, '-m', 'pip', 'install', '--upgrade', '-q', 'cf-precheck'],
27762773
check=True,
2777-
capture_output=True
2774+
capture_output=True,
2775+
text=True,
27782776
)
2779-
console.print("[green]✓[/green] Precheck Docker image ready")
2777+
try:
2778+
result = subprocess.run(
2779+
[sys.executable, '-c', 'from cf_precheck import __version__; print(__version__)'],
2780+
capture_output=True, text=True,
2781+
)
2782+
version = result.stdout.strip()
2783+
console.print(f"[green]✓[/green] cf-precheck v{version} installed")
2784+
except Exception:
2785+
console.print("[green]✓[/green] cf-precheck installed")
27802786
except subprocess.CalledProcessError as e:
27812787
maybe_abort_no_space(e, "Precheck install")
27822788
had_errors = True
2783-
console.print(f"[red]✗[/red] Failed to pull precheck image: {e}")
2789+
console.print(f"[red]✗[/red] Failed to install cf-precheck: {e}")
27842790
if e.stderr:
27852791
console.print(f"[dim]{e.stderr}[/dim]")
27862792

@@ -3252,30 +3258,27 @@ def precheck(project_root, skip_checks, magic_drc, checks, dry_run):
32523258

32533259
pdk_path = pdk_root / pdk
32543260

3255-
precheck_args = [
3261+
docker_image = 'chipfoundry/mpw_precheck:latest'
3262+
3263+
docker_cmd = [
3264+
'docker', 'run', '--rm',
3265+
'-v', f'{project_root_path}:{project_root_path}',
3266+
'-v', f'{pdk_root}:{pdk_root}',
3267+
docker_image,
3268+
'cf-precheck',
32563269
'-i', str(project_root_path),
32573270
'-p', str(pdk_path),
32583271
'-c', '/opt/caravel',
32593272
]
32603273

32613274
if magic_drc:
3262-
precheck_args.append('--magic-drc')
3275+
docker_cmd.append('--magic-drc')
32633276

32643277
if skip_checks:
3265-
precheck_args.extend(['--skip-checks'] + list(skip_checks))
3278+
docker_cmd.extend(['--skip-checks'] + list(skip_checks))
32663279

32673280
if checks:
3268-
precheck_args.extend(list(checks))
3269-
3270-
precheck_cmd = 'pip3 install -q cf-precheck && cf-precheck ' + ' '.join(precheck_args)
3271-
3272-
docker_cmd = [
3273-
'docker', 'run', '--rm',
3274-
'-v', f'{project_root_path}:{project_root_path}',
3275-
'-v', f'{pdk_root}:{pdk_root}',
3276-
'chipfoundry/mpw_precheck:latest',
3277-
'bash', '-c', precheck_cmd,
3278-
]
3281+
docker_cmd.extend(list(checks))
32793282

32803283
checks_display = ', '.join(checks) if checks else 'All checks'
32813284
console.print("\n" + "="*60)
@@ -3294,6 +3297,26 @@ def precheck(project_root, skip_checks, magic_drc, checks, dry_run):
32943297
console.print("[dim]" + ' '.join(docker_cmd) + "[/dim]")
32953298
return
32963299

3300+
# Pull/update Docker image before running
3301+
console.print(f"[cyan]Checking for Docker image updates...[/cyan]")
3302+
try:
3303+
subprocess.run(
3304+
['docker', 'pull', docker_image],
3305+
check=True,
3306+
capture_output=True,
3307+
)
3308+
console.print(f"[green]✓[/green] Docker image up to date")
3309+
except subprocess.CalledProcessError:
3310+
# Image might already be available locally, warn but continue
3311+
result = subprocess.run(
3312+
['docker', 'image', 'inspect', docker_image],
3313+
capture_output=True,
3314+
)
3315+
if result.returncode != 0:
3316+
console.print(f"[red]✗[/red] Docker image '{docker_image}' not found. Run 'cf setup --only-precheck' or check your connection.")
3317+
return
3318+
console.print("[yellow]⚠[/yellow] Could not check for image updates (using cached image)")
3319+
32973320
console.print("[cyan]Running cf-precheck...[/cyan]\n")
32983321

32993322
try:

0 commit comments

Comments
 (0)