Workspace ManagerstableAPI Reference

Choose documentation 3

stable

Current version

stable
English

Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

tmuxp.workspace.builder.prepended_sys_path

tmuxp.workspace.builder.prepended_sys_path ( paths: list[pathlib.Path] | None, ) → Iterator[None]

Temporarily prepend directories to sys.path, restoring it on exit.

Description#

Paths are prepended in order (first entry ends up at sys.path[0]). An empty or falsy paths is a no-op. Uses only literal directory entries; it avoids site.addsitedir (which runs .pth startup code).

Examples#

>>> import sys
>>> ext = tmp_path / "ext"
>>> ext.mkdir()
>>> before = list(sys.path)
>>> with prepended_sys_path([ext]):
... sys.path[0] == str(ext)
True
>>> sys.path == before
True
Parameters
Esc

Type to search.

Reference preview Open reference