package python

import (
	"fmt"

	"zlh-agent/internal/provision/executil"
	"zlh-agent/internal/provision/markers"
	"zlh-agent/internal/state"
)

func Install(cfg state.Config) error {
	const marker = "devcontainer-python"

	if markers.IsPresent(marker) {
		return nil
	}

	if err := executil.RunEmbeddedScript(
		"devcontainer/python/install.sh",
		"RUNTIME=python",
		"ARCHIVE_EXT=tar.xz",
		"RUNTIME_VERSION="+cfg.Version,
	); err != nil {
		return fmt.Errorf("python devcontainer install failed: %w", err)
	}

	return markers.Write(marker)
}
