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

Function _find_executable

Lib/_osx_support.py:30–53  ·  view source on GitHub ↗

Tries to find 'executable' in the directories listed in 'path'. A string listing directories separated by 'os.pathsep'; defaults to os.environ['PATH']. Returns the complete filename or None if not found.

(executable, path=None)

Source from the content-addressed store, hash-verified

28
29
30def _find_executable(executable, path=None):
31 """Tries to find 'executable' in the directories listed in 'path'.
32
33 A string listing directories separated by 'os.pathsep'; defaults to
34 os.environ['PATH']. Returns the complete filename or None if not found.
35 """
36 if path is None:
37 path = os.environ['PATH']
38
39 paths = path.split(os.pathsep)
40 base, ext = os.path.splitext(executable)
41
42 if (sys.platform == 'win32') and (ext != '.exe'):
43 executable = executable + '.exe'
44
45 if not os.path.isfile(executable):
46 for p in paths:
47 f = os.path.join(p, executable)
48 if os.path.isfile(f):
49 # the file exists, we have a shot at spawn working
50 return f
51 return None
52 else:
53 return executable
54
55
56def _read_output(commandstring, capture_stderr=False):

Callers 2

_find_build_toolFunction · 0.85

Calls 4

splitextMethod · 0.80
splitMethod · 0.45
isfileMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…