MCPcopy Create free account
hub / github.com/pybind/pybind11 / tmp_chdir

Function tmp_chdir

pybind11/setup_helpers.py:213–225  ·  view source on GitHub ↗

Prepare and enter a temporary directory, cleanup when done

()

Source from the content-addressed store, hash-verified

211
212@contextlib.contextmanager
213def tmp_chdir() -> Iterator[str]:
214 "Prepare and enter a temporary directory, cleanup when done"
215
216 # Threadsafe
217 with tmp_chdir_lock:
218 olddir = os.getcwd()
219 try:
220 tmpdir = tempfile.mkdtemp()
221 os.chdir(tmpdir)
222 yield tmpdir
223 finally:
224 os.chdir(olddir)
225 shutil.rmtree(tmpdir)
226
227
228# cf http://bugs.python.org/issue26689

Callers 1

has_flagFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected