@@ -25,59 +25,31 @@ public override DependencyStatus DetectPython()
2525
2626 try
2727 {
28- // 1. Check explicit common Homebrew/system paths first to avoid PATH ambiguity
29- // This prioritizes Homebrew versions (often newer) over system versions
30- var candidatePaths = new [ ]
31- {
32- "/opt/homebrew/bin/python3" ,
33- "/usr/local/bin/python3" ,
34- "/opt/homebrew/bin/python3.13" ,
35- "/opt/homebrew/bin/python3.12" ,
36- "/opt/homebrew/bin/python3.11" ,
37- "/opt/homebrew/bin/python3.10" ,
38- "/usr/local/bin/python3.13" ,
39- "/usr/local/bin/python3.12" ,
40- "/usr/local/bin/python3.11" ,
41- "/usr/local/bin/python3.10"
42- } ;
43-
44- foreach ( var path in candidatePaths )
28+ // 1. Try 'which' command with augmented PATH (prioritizing Homebrew)
29+ if ( TryFindInPath ( "python3" , out string pathResult ) ||
30+ TryFindInPath ( "python" , out pathResult ) )
4531 {
46- if ( File . Exists ( path ) && TryValidatePython ( path , out string v , out string p ) )
32+ if ( TryValidatePython ( pathResult , out string version , out string fullPath ) )
4733 {
4834 status . IsAvailable = true ;
49- status . Version = v ;
50- status . Path = p ;
51- status . Details = $ "Found Python { v } at { p } ";
35+ status . Version = version ;
36+ status . Path = fullPath ;
37+ status . Details = $ "Found Python { version } at { fullPath } ";
5238 return status ;
5339 }
5440 }
5541
56- // 2. Try running python directly from PATH (fallback)
57- if ( TryValidatePython ( "python3" , out string version , out string fullPath ) ||
58- TryValidatePython ( "python" , out version , out fullPath ) )
42+ // 2. Fallback: Try running python directly from PATH
43+ if ( TryValidatePython ( "python3" , out string v , out string p ) ||
44+ TryValidatePython ( "python" , out v , out p ) )
5945 {
6046 status . IsAvailable = true ;
61- status . Version = version ;
62- status . Path = fullPath ;
63- status . Details = $ "Found Python { version } in PATH";
47+ status . Version = v ;
48+ status . Path = p ;
49+ status . Details = $ "Found Python { v } in PATH";
6450 return status ;
6551 }
6652
67- // 3. Fallback: try 'which' command
68- if ( TryFindInPath ( "python3" , out string pathResult ) ||
69- TryFindInPath ( "python" , out pathResult ) )
70- {
71- if ( TryValidatePython ( pathResult , out version , out fullPath ) )
72- {
73- status . IsAvailable = true ;
74- status . Version = version ;
75- status . Path = fullPath ;
76- status . Details = $ "Found Python { version } in PATH";
77- return status ;
78- }
79- }
80-
8153 status . ErrorMessage = "Python not found in PATH or standard locations" ;
8254 status . Details = "Install Python 3.10+ via Homebrew ('brew install python3') and ensure it's in your PATH." ;
8355 }
0 commit comments