mirror of https://github.com/stashapp/stash.git
Apply python path resolution to plugins (#1990)
* Symlink python3 to python * Apply path resolution to plugins
This commit is contained in:
parent
a7ed0a7004
commit
2c7e0f0571
|
@ -12,6 +12,7 @@ RUN if [ "$TARGETPLATFORM" = "linux/arm/v6" ]; then BIN=stash-pi; \
|
|||
FROM --platform=$TARGETPLATFORM alpine:latest AS app
|
||||
COPY --from=binary /stash /usr/bin/
|
||||
RUN apk add --no-cache ca-certificates python3 py3-requests py3-requests-toolbelt py3-lxml py3-pip ffmpeg vips-tools && pip install --no-cache-dir mechanicalsoup cloudscraper
|
||||
RUN ln -s /usr/bin/python3 /usr/bin/python
|
||||
ENV STASH_CONFIG_FILE=/root/.stash/config.yml
|
||||
|
||||
EXPOSE 9999
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue