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

Method find_py

Lib/test/test_launcher.py:173–211  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

171
172 @classmethod
173 def find_py(cls):
174 py_exe = None
175 if sysconfig.is_python_build():
176 py_exe = Path(sys.executable).parent / PY_EXE
177 else:
178 for p in os.getenv("PATH").split(";"):
179 if p:
180 py_exe = Path(p) / PY_EXE
181 if py_exe.is_file():
182 break
183 else:
184 py_exe = None
185
186 # Test launch and check version, to exclude installs of older
187 # releases when running outside of a source tree
188 if py_exe:
189 try:
190 with subprocess.Popen(
191 [py_exe, "-h"],
192 stdin=subprocess.PIPE,
193 stdout=subprocess.PIPE,
194 stderr=subprocess.PIPE,
195 encoding="ascii",
196 errors="ignore",
197 ) as p:
198 p.stdin.close()
199 version = next(p.stdout, "\n").splitlines()[0].rpartition(" ")[2]
200 p.stdout.read()
201 p.wait(10)
202 if not sys.version.startswith(version):
203 py_exe = None
204 except OSError:
205 py_exe = None
206
207 if not py_exe:
208 raise unittest.SkipTest(
209 "cannot locate '{}' for test".format(PY_EXE)
210 )
211 return py_exe
212
213 def get_py_exe(self):
214 if not self.py_exe:

Callers 2

get_py_exeMethod · 0.95
run_pyMethod · 0.95

Calls 10

PathClass · 0.90
splitMethod · 0.45
is_fileMethod · 0.45
closeMethod · 0.45
rpartitionMethod · 0.45
splitlinesMethod · 0.45
readMethod · 0.45
waitMethod · 0.45
startswithMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected