Apply python path resolution to plugins (#1990)

* Symlink python3 to python
* Apply path resolution to plugins
This commit is contained in:
kermieisinthehouse
2021-11-11 14:21:52 -08:00
committed by GitHub
parent a7ed0a7004
commit 2c7e0f0571
2 changed files with 21 additions and 0 deletions

View File

@@ -29,6 +29,19 @@ type rawPluginTask struct {
done chan bool
}
func FindPythonExecutable() (string, error) {
_, err := exec.LookPath("python3")
if err != nil {
_, err = exec.LookPath("python")
if err != nil {
return "", err
}
return "python", nil
}
return "python3", nil
}
func (t *rawPluginTask) Start() error {
if t.started {
return errors.New("task already started")
@@ -39,6 +52,13 @@ func (t *rawPluginTask) Start() error {
return fmt.Errorf("empty exec value in operation %s", t.operation.Name)
}
if command[0] == "python" || command[0] == "python3" {
executable, err := FindPythonExecutable()
if err == nil {
command[0] = executable
}
}
cmd := exec.Command(command[0], command[1:]...)
stdin, err := cmd.StdinPipe()