PyDocs

Python Runtime Services

site

Append module search paths for third-party packages to sys.path.

****************************************************************
* This module is automatically imported during initialization. *
****************************************************************

This will append site-specific paths to the module search path.  On
Unix (including Mac OSX), it starts with sys.prefix and
sys.exec_prefix (if different) and appends
lib/python<version>/site-packages.
On other platforms (such as Windows), it tries each of the
prefixes directly, as well as with lib/site-packages appended.  The
resulting directories, if they exist, are appended to sys.path, and
also inspected for path configuration files.

If a file named "pyvenv.cfg" exists one directory above sys.executable,
sys.prefix and sys.exec_prefix are set to that directory and
it is also checked for site-packages (sys.base_prefix and
sys.base_exec_prefix will always be the "real" prefixes of the Python
installation). If "pyvenv.cfg" (a bootstrap configuration file) contains
the key "include-system-site-packages" set to "true" (case-insensitive),
the system-level prefixes will still also be searched for site-packages;
otherwise they won't.

Two kinds of configuration files are processed in each site-packages
directory:

- <name>.pth files extend sys.path with additional directories (one per
  line).  Lines starting with "import" are deprecated (see PEP 829).

- <name>.start files specify startup entry points using the pkg.mod:callable
  syntax.  These are resolved via pkgutil.resolve_name() and called with no
  arguments.

When called from main(), all .pth path extensions are applied before any
.start entry points are executed, ensuring that paths are available before
startup code runs.

See the documentation for the site module for full details:
https://docs.python.org/3/library/site.html
Symbols in site

a

addsitedir
Add a site directory and process its startup files.

e

ENABLE_USER_SITE
Flag showing the status of the user site-packages directory.

g

getsitepackages
Returns a list containing all global site-packages directories.
getuserbase
Returns the `user base` directory path.
getusersitepackages
Returns the user-specific site-packages directory path.

m

main
Add standard site-specific directories to the module search path.
makepath
Join paths with os.path.join(), attempt to make the result absolute with os.path.abspath(), and return a 2-tuple containing the absolute path and its case-normalized form as produced by os.path.normc…

p

PREFIXES
A list of prefixes for site-packages directories.

s

StartupState
Per-batch accumulator for .pth and .start file processing.

u

USER_BASE
Path to the base directory for the user site-packages.
USER_SITE
Path to the user site-packages for the running Python.