PyDocs

Nav

Python Runtime Services

StartupState

site

class · Added in 3.15 (source)
  • StartupState(known_paths=None)
Per-batch accumulator for .pth and .start file processing.

A StartupState collects sys.path extensions, deprecated .pth import lines,
and .start entry points read from one or more site-packages directories.
Calling process() applies them in PEP 829 order: paths are added to
sys.path first, then import lines from .pth files (skipping any with a
matching .start), then entry points from .start files.

State lives entirely on the instance; there is no module-level pending
state.  This is what makes the module reentrancy-safe: a site.addsitedir()
call reached recursively from an exec'd import line or a .start entry
point operates on a different StartupState than the one being processed by
the outer call.

The internal data is intentionally private.  The lower-level write
methods (_record_sitedir(), _read_pth_file(), _read_start_file()) are
private to the site module; the public surface is addsitedir(),
addusersitepackages(), addsitepackages(), and process().
Members of StartupState

a

addsitedir
Add a site directory and accumulate its .pth and .start startup data.
addsitepackages
Add global site-packages directories, if they exist.
addusersitepackages
Add the per-user site-packages directory, if enabled.

p

process
Apply accumulated state in PEP 829 order.
0 Examples
No examples for site/StartupState.
See Also
No see-alsos for site/StartupState
0 Notes
No notes for StartupState