MCPcopy Create free account
hub / github.com/pytorch/pytorch / which

Function which

tools/setup_helpers/__init__.py:6–17  ·  view source on GitHub ↗
(thefile: str)

Source from the content-addressed store, hash-verified

4
5
6def which(thefile: str) -> Optional[str]:
7 path = os.environ.get("PATH", os.defpath).split(os.pathsep)
8 for d in path:
9 fname = os.path.join(d, thefile)
10 fnames = [fname]
11 if sys.platform == "win32":
12 exts = os.environ.get("PATHEXT", "").split(os.pathsep)
13 fnames += [fname + ext for ext in exts]
14 for name in fnames:
15 if os.access(name, os.F_OK | os.X_OK) and not os.path.isdir(name):
16 return name
17 return None

Callers 2

cmake.pyFile · 0.85
_get_cmake_commandMethod · 0.85

Calls 3

splitMethod · 0.45
getMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…