diff options
| author | ewy <ewy0@protonmail.com> | 2026-04-14 20:13:13 +0200 |
|---|---|---|
| committer | ewy <ewy0@protonmail.com> | 2026-04-14 20:13:13 +0200 |
| commit | f6963b1c451afcb2f0d0104f38178235e52f8b63 (patch) | |
| tree | 791ac29577c358dcc588d2dc8db67a7be5e9b161 /runner/python/proj.go | |
| parent | f26f2a1b0d9d2772ce42da34fd99762e5aa3ad32 (diff) | |
remove all name repetition
Diffstat (limited to 'runner/python/proj.go')
| -rw-r--r-- | runner/python/proj.go | 49 |
1 files changed, 49 insertions, 0 deletions
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 +} |
