Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pkg/functions/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func runPython(ctx context.Context, job *Job) (err error) {
if job.verbose {
fmt.Printf("python -m venv .venv\n")
}
cmd := exec.CommandContext(ctx, "python", "-m", "venv", ".venv")
cmd := exec.CommandContext(ctx, pythonCmd(), "-m", "venv", ".venv")
cmd.Dir = job.Dir()
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
Expand Down Expand Up @@ -360,3 +360,11 @@ func choosePort(iface, preferredPort string) (string, error) {
}
return port, nil
}

func pythonCmd() string {
_, err := exec.LookPath("python")
if err != nil {
return "python3"
}
return "python"
}
12 changes: 10 additions & 2 deletions pkg/oci/python_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (b pythonBuilder) Base(customBase string) string {
if customBase != "" {
return customBase
}
cmd := exec.Command("python", "-V")
cmd := exec.Command(pythonCmd(), "-V")
out, err := cmd.CombinedOutput()
if err != nil {
return defaultPythonBase
Expand Down Expand Up @@ -61,7 +61,7 @@ func (b pythonBuilder) WriteShared(job buildJob) (layers []imageLayer, err error
if job.verbose {
fmt.Printf("python -m venv .venv\n")
}
cmd := exec.CommandContext(job.ctx, "python", "-m", "venv", ".venv")
cmd := exec.CommandContext(job.ctx, pythonCmd(), "-m", "venv", ".venv")
cmd.Dir = job.buildDir()
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
Expand Down Expand Up @@ -205,3 +205,11 @@ func newPythonLibTarball(job buildJob, root, target string) error {
func (b pythonBuilder) WritePlatform(ctx buildJob, p v1.Platform) (layers []imageLayer, err error) {
return []imageLayer{}, nil
}

func pythonCmd() string {
_, err := exec.LookPath("python")
if err != nil {
return "python3"
}
return "python"
}
Loading