From f6963b1c451afcb2f0d0104f38178235e52f8b63 Mon Sep 17 00:00:00 2001 From: ewy Date: Tue, 14 Apr 2026 20:13:13 +0200 Subject: remove all name repetition --- runner/python/proj.go | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 runner/python/proj.go (limited to 'runner/python/proj.go') diff --git a/runner/python/proj.go b/runner/python/proj.go new file mode 100644 index 0000000..9a711bd --- /dev/null +++ b/runner/python/proj.go @@ -0,0 +1,49 @@ +package python + +import ( + "os/exec" + "path/filepath" + "pik/model" + "pik/runner" +) + +type Project struct { + runner.BaseTarget + Cmd string +} + +type Hydrated struct { + runner.BaseHydration[*Project] +} + +func (h *Hydrated) Icon() string { + return "\uE606" +} + +func (h *Hydrated) Description() string { + return h.BaseTarget.Cmd +} + +func (p *Project) Create(s *model.Source) *exec.Cmd { + var cmd []string + if Python.Uv != "" { + cmd = []string{Python.Uv, "run", "--", p.Cmd} + } else if venv := Python.VenvFor(s); venv != "" { + cmd = []string{filepath.Join(s.Path, venv, "bin", "python"), p.Cmd} + } + return exec.Command(cmd[0], cmd[1:]...) +} + +func (p *Project) Sub() []string { + return nil +} + +func (p *Project) Label() string { + return p.Cmd +} + +func (p *Project) Hydrate(src *model.Source) (model.HydratedTarget, error) { + return &Hydrated{ + BaseHydration: runner.Hydrated(p), + }, nil +} -- cgit v1.3