MCPcopy Index your code
hub / github.com/python/cpython / _find_tool

Function _find_tool

Tools/jit/_llvm.py:83–109  ·  view source on GitHub ↗
(tool: str, llvm_version: str, *, echo: bool = False)

Source from the content-addressed store, hash-verified

81
82@_async_cache
83async def _find_tool(tool: str, llvm_version: str, *, echo: bool = False) -> str | None:
84 # Unversioned executables:
85 path = tool
86 if await _check_tool_version(path, llvm_version, echo=echo):
87 return path
88 # Versioned executables:
89 path = f"{tool}-{llvm_version}"
90 if await _check_tool_version(path, llvm_version, echo=echo):
91 return path
92 # PCbuild externals:
93 externals = os.environ.get("EXTERNALS_DIR", _targets.EXTERNALS)
94 path = os.path.join(externals, _EXTERNALS_LLVM_TAG, "bin", tool)
95 # On Windows, executables need .exe extension
96 if os.name == "nt" and not path.endswith(".exe"):
97 path_with_exe = path + ".exe"
98 if os.path.exists(path_with_exe):
99 path = path_with_exe
100 if await _check_tool_version(path, llvm_version, echo=echo):
101 return path
102 # Homebrew-installed executables:
103 prefix = await _get_brew_llvm_prefix(llvm_version, echo=echo)
104 if prefix is not None:
105 path = os.path.join(prefix, "bin", tool)
106 if await _check_tool_version(path, llvm_version, echo=echo):
107 return path
108 # Nothing found:
109 return None
110
111
112async def maybe_run(

Callers 1

maybe_runFunction · 0.85

Calls 6

_check_tool_versionFunction · 0.85
_get_brew_llvm_prefixFunction · 0.85
getMethod · 0.45
joinMethod · 0.45
endswithMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…