getWindowsDefaultPythonVersion reads Python version from static TOML.
()
| 309 | |
| 310 | // getWindowsDefaultPythonVersion reads Python version from static TOML. |
| 311 | func getWindowsDefaultPythonVersion() string { |
| 312 | // Determine current architecture. |
| 313 | arch := runtime.GOARCH |
| 314 | switch arch { |
| 315 | case "amd64", "x86_64": |
| 316 | arch = "x86_64" |
| 317 | case "arm64": |
| 318 | arch = "aarch64" |
| 319 | } |
| 320 | |
| 321 | staticFile := fmt.Sprintf("static/%s-%s.toml", arch, runtime.GOOS) |
| 322 | bytes, err := static.ReadFile(staticFile) |
| 323 | if err != nil { |
| 324 | panic(fmt.Sprintf("failed to read %s", staticFile)) |
| 325 | } |
| 326 | |
| 327 | var buildTools BuildTools |
| 328 | if err := toml.Unmarshal(bytes, &buildTools); err != nil { |
| 329 | panic(fmt.Sprintf("failed to decode %s: %s", staticFile, err)) |
| 330 | } |
| 331 | |
| 332 | pythonTool, err := buildTools.findTool(nil, "python3") |
| 333 | if err == nil && pythonTool != nil && pythonTool.Version != "" { |
| 334 | return pythonTool.Version |
| 335 | } |
| 336 | |
| 337 | panic("failed to read windows default python version") |
| 338 | } |
| 339 | |
| 340 | func shouldUseConda(ctx context.Context) bool { |
| 341 | // If no Python config or version is specified, use system Python. |
no test coverage detected