(name: str)
| 182 | |
| 183 | |
| 184 | def get_executable_path(name: str) -> Path | None: |
| 185 | # Add suffix for Windows executables |
| 186 | name += ".exe" if sys.platform == "win32" and not name.endswith(".exe") else "" |
| 187 | |
| 188 | path = os.path.join(sysconfig.get_path("scripts"), name) |
| 189 | |
| 190 | # The executable in the current interpreter's scripts directory. |
| 191 | if os.path.exists(path): |
| 192 | return Path(path) |
| 193 | |
| 194 | # The executable in the global environment. |
| 195 | environment_path = shutil.which(name) |
| 196 | if environment_path: |
| 197 | return Path(environment_path) |
| 198 | |
| 199 | return None |
no test coverage detected