NewPythonRuntime 创建 Python 运行时
(config *RuntimeConfig)
| 71 | |
| 72 | // NewPythonRuntime 创建 Python 运行时 |
| 73 | func NewPythonRuntime(config *RuntimeConfig) *PythonRuntime { |
| 74 | if config == nil { |
| 75 | config = DefaultRuntimeConfig() |
| 76 | } |
| 77 | |
| 78 | // 查找 Python 可执行文件 |
| 79 | pythonPath := "python3" |
| 80 | if path, err := exec.LookPath("python3"); err == nil { |
| 81 | pythonPath = path |
| 82 | } else if path, err := exec.LookPath("python"); err == nil { |
| 83 | pythonPath = path |
| 84 | } |
| 85 | |
| 86 | return &PythonRuntime{ |
| 87 | config: config, |
| 88 | pythonPath: pythonPath, |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | func (r *PythonRuntime) Language() Language { |
| 93 | return LangPython |