MCPcopy Create free account
hub / github.com/RightNow-AI/rightnow-cli / ToolchainDetector

Class ToolchainDetector

rightnow_cli/utils/detection.py:40–933  ·  view source on GitHub ↗

Advanced cross-platform toolchain detection. Caches results for performance. Checks multiple locations for maximum reliability.

Source from the content-addressed store, hash-verified

38
39
40class ToolchainDetector:
41 """
42 Advanced cross-platform toolchain detection.
43
44 Caches results for performance.
45 Checks multiple locations for maximum reliability.
46 """
47
48 def __init__(self, config_paths: Optional[Dict[str, str]] = None):
49 """
50 Initialize detector with optional configured compiler paths.
51
52 Args:
53 config_paths: Optional dict of configured paths (e.g., {'nvcc': '/path/to/nvcc', 'cl': '/path/to/cl.exe'})
54 """
55 self._cache: Dict[str, ToolInfo] = {}
56 self.platform = platform.system()
57 self.config_paths = config_paths or {}
58
59 # ============================================================================
60 # NVCC Detection - CUDA Compiler
61 # ============================================================================
62
63 def detect_nvcc(self) -> ToolInfo:
64 """
65 Detect NVCC (CUDA compiler) with advanced cross-platform support.
66
67 Checks:
68 1. Configured path (from config)
69 2. PATH environment variable
70 3. CUDA_PATH environment variable
71 4. Common installation locations
72 5. Extracts version information
73
74 Returns:
75 ToolInfo with availability, path, version
76 """
77 if 'nvcc' in self._cache:
78 return self._cache['nvcc']
79
80 # Check configured path first (highest priority)
81 if 'nvcc' in self.config_paths and self.config_paths['nvcc']:
82 nvcc_configured = Path(self.config_paths['nvcc'])
83 if nvcc_configured.exists():
84 version = self._get_nvcc_version(str(nvcc_configured))
85 info = ToolInfo(
86 available=True,
87 path=str(nvcc_configured),
88 version=version
89 )
90 self._cache['nvcc'] = info
91 return info
92
93 # Check PATH (fast auto-detection)
94 nvcc_path = shutil.which('nvcc')
95
96 if nvcc_path:
97 version = self._get_nvcc_version(nvcc_path)

Callers 5

compile_kernelMethod · 0.85
executeMethod · 0.85
get_detectorFunction · 0.85
run_setup_wizardFunction · 0.85
show_compiler_statusFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected