MCPcopy Index your code
hub / github.com/celer-pkg/celer / GetVersion

Method GetVersion

buildtools/python/python_system.go:23–54  ·  view source on GitHub ↗

GetVersion detects the system python3 version Returns version string (e.g., "3.11.0") or empty string if not found.

()

Source from the content-addressed store, hash-verified

21// GetVersion detects the system python3 version
22// Returns version string (e.g., "3.11.0") or empty string if not found.
23func (s *SystemPython) GetVersion() string {
24 var (
25 output []byte
26 err error
27 )
28
29 if runtime.GOOS == "windows" {
30 // On Windows, try python.exe or python3.exe
31 output, err = exec.Command("python", "--version").Output()
32 if err != nil {
33 output, err = exec.Command("python3", "--version").Output()
34 }
35 } else {
36 // On Unix-like systems, try python3
37 output, err = exec.Command("python3", "--version").Output()
38 if err != nil {
39 output, err = exec.Command("python", "--version").Output()
40 }
41 }
42
43 if err != nil {
44 return ""
45 }
46
47 // Parse "Python 3.11.0" -> "3.11.0"
48 versionStr := strings.TrimSpace(string(output))
49 parts := strings.Fields(versionStr)
50 if len(parts) >= 2 {
51 return parts[1]
52 }
53 return ""
54}
55
56func (s *SystemPython) GetExecutable() (string, error) {
57 switch runtime.GOOS {

Callers

nothing calls this directly

Calls 1

CommandMethod · 0.65

Tested by

no test coverage detected