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

Function _setup_environment

Lib/profiling/sampling/_sync_coordinator.py:109–126  ·  view source on GitHub ↗

Set up the execution environment. Args: cwd: Working directory to change to Raises: TargetError: If unable to set up environment

(cwd: str)

Source from the content-addressed store, hash-verified

107
108
109def _setup_environment(cwd: str) -> None:
110 """
111 Set up the execution environment.
112
113 Args:
114 cwd: Working directory to change to
115
116 Raises:
117 TargetError: If unable to set up environment
118 """
119 try:
120 os.chdir(cwd)
121 except OSError as e:
122 raise TargetError(f"Failed to change to directory {cwd}: {e}") from e
123
124 # Add current directory to sys.path if not present (for module imports)
125 if cwd not in sys.path:
126 sys.path.insert(0, cwd)
127
128
129def _execute_module(module_name: str, module_args: List[str]) -> None:

Callers 1

mainFunction · 0.85

Calls 2

TargetErrorClass · 0.85
insertMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…