| 37 | |
| 38 | |
| 39 | def _find_executable(exe_name): |
| 40 | # 1. Installed wheel layout: osrm/bin/ |
| 41 | candidate = _BIN_DIR / exe_name |
| 42 | if candidate.is_file(): |
| 43 | return candidate |
| 44 | |
| 45 | # 2. Editable install: look in CMake build directories |
| 46 | project_root = Path(__file__).parent.parent.parent.parent |
| 47 | for build_dir in sorted(project_root.glob("build/*/"), reverse=True): |
| 48 | candidate = build_dir / exe_name |
| 49 | if candidate.is_file(): |
| 50 | return candidate |
| 51 | |
| 52 | # 3. System PATH |
| 53 | found = shutil.which(exe_name) |
| 54 | if found: |
| 55 | return Path(found) |
| 56 | |
| 57 | return None |
| 58 | |
| 59 | |
| 60 | executable = _find_executable(exe_name) |