package python

import (
	"fmt"
	"os"
	"os/exec"

	"zlh-agent/internal/state"
)

const (
	pythonBin = "/opt/zlh/runtimes/python/bin/python3"
	pipBin    = "/opt/zlh/runtimes/python/bin/pip3"
)

func Verify(cfg state.Config) error {

	// python3 must exist
	if _, err := os.Stat(pythonBin); err != nil {
		return fmt.Errorf("python3 binary missing at %s", pythonBin)
	}

	// python3 must execute
	if err := exec.Command(pythonBin, "--version").Run(); err != nil {
		return fmt.Errorf("python3 runtime not executable: %w", err)
	}

	// pip must exist (completeness check only)
	if _, err := os.Stat(pipBin); err != nil {
		return fmt.Errorf("pip3 missing at %s", pipBin)
	}

	// Do NOT execute pip (PATH + env dependent)
	return nil
}
