zlh-agent/internal/provision/devcontainer/python/verify.go
2025-12-21 22:11:44 +00:00

36 lines
730 B
Go

package python
import (
"fmt"
"os"
"os/exec"
"zlh-agent/internal/state"
)
const (
pythonBin = "/opt/zlh/runtime/python/bin/python3"
pipBin = "/opt/zlh/runtime/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
}