MCPcopy Index your code
hub / github.com/python/mypy / run_with_librt

Function run_with_librt

mypyc/test/librt_cache.py:211–236  ·  view source on GitHub ↗

Run a Python file in a subprocess with built librt available. This runs the file in a fresh Python process where the built librt is at the front of sys.path, avoiding conflicts with any system librt. Args: file_path: Path to Python file to execute. experimental: Whether

(
    file_path: str, experimental: bool = True, check: bool = True, opt_level: str = "0"
)

Source from the content-addressed store, hash-verified

209
210
211def run_with_librt(
212 file_path: str, experimental: bool = True, check: bool = True, opt_level: str = "0"
213) -> subprocess.CompletedProcess[str]:
214 """Run a Python file in a subprocess with built librt available.
215
216 This runs the file in a fresh Python process where the built librt
217 is at the front of sys.path, avoiding conflicts with any system librt.
218
219 Args:
220 file_path: Path to Python file to execute.
221 experimental: Whether to use experimental features.
222 check: If True, raise CalledProcessError on non-zero exit.
223 opt_level: Optimization level ("0".."3") used when building librt.
224
225 Returns:
226 CompletedProcess with stdout, stderr, and returncode.
227 """
228 librt_path = get_librt_path(experimental, opt_level=opt_level)
229 # Prepend librt path to PYTHONPATH
230 env = os.environ.copy()
231 existing = env.get("PYTHONPATH", "")
232 env["PYTHONPATH"] = librt_path + (os.pathsep + existing if existing else "")
233
234 return subprocess.run(
235 [sys.executable, file_path], capture_output=True, text=True, check=check, env=env
236 )

Callers

nothing calls this directly

Calls 4

get_librt_pathFunction · 0.85
copyMethod · 0.45
getMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…