blob: 7d112575b7ff193b11fdafc6552895ac12e2ee69 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package python
import (
"git.ewy.one/pik.git/model"
"git.ewy.one/pik.git/runner"
"os/exec"
"path/filepath"
)
type Project struct {
runner.BaseTarget
Cmd string
}
func (p *Project) File(src *model.Source) string {
return Python.files[src.Path]
}
type Hydrated struct {
runner.BaseHydration[*Project]
}
func (h *Hydrated) Description(src *model.HydratedSource) string {
return h.Self.Cmd
}
func (h *Hydrated) Icon() string {
return "\uE606"
}
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
}
|