17 lines
411 B
Go
17 lines
411 B
Go
package service
|
|
|
|
import (
|
|
"path/filepath"
|
|
"runtime"
|
|
)
|
|
|
|
// getPythonPath 获取虚拟环境中的Python解释器路径(跨平台)
|
|
func getPythonPath(backendDir string) string {
|
|
if runtime.GOOS == "windows" {
|
|
// Windows: venv\Scripts\python.exe
|
|
return filepath.Join(backendDir, "venv", "Scripts", "python.exe")
|
|
}
|
|
// Linux/Mac: venv/bin/python
|
|
return filepath.Join(backendDir, "venv", "bin", "python")
|
|
}
|