{
	"id": "13261394-2830-452d-b93b-ed2fdcb4adc6",
	"created_at": "2026-04-06T00:16:05.923894Z",
	"updated_at": "2026-04-10T13:12:07.218966Z",
	"deleted_at": null,
	"sha1_hash": "e35b1e921b19ba7e9250521add8431b3293c1775",
	"title": "site — Site-specific configuration hook",
	"llm_title": "",
	"authors": "",
	"file_creation_date": "0001-01-01T00:00:00Z",
	"file_modification_date": "0001-01-01T00:00:00Z",
	"file_size": 115741,
	"plain_text": "site — Site-specific configuration hook\r\nArchived: 2026-04-05 22:08:15 UTC\r\nSource code: Lib/site.py\r\nThis module is automatically imported during initialization. The automatic import can be suppressed using the\r\ninterpreter’s -S option.\r\nImporting this module normally appends site-specific paths to the module search path and adds callables,\r\nincluding help() to the built-in namespace. However, Python startup option -S blocks this and this module\r\ncan be safely imported with no automatic modifications to the module search path or additions to the builtins. To\r\nexplicitly trigger the usual site-specific additions, call the main() function.\r\nChanged in version 3.3: Importing the module used to trigger paths manipulation even when using -S .\r\nIt starts by constructing up to four directories from a head and a tail part. For the head part, it uses sys.prefix\r\nand sys.exec_prefix ; empty heads are skipped. For the tail part, it uses the empty string and then lib/site-packages (on Windows) or lib/pythonX.Y[t]/site-packages (on Unix and macOS). (The optional suffix “t”\r\nindicates the free-threaded build, and is appended if \"t\" is present in the sys.abiflags constant.) For each of\r\nthe distinct head-tail combinations, it sees if it refers to an existing directory, and if so, adds it to sys.path and\r\nalso inspects the newly added path for configuration files.\r\nChanged in version 3.5: Support for the “site-python” directory has been removed.\r\nChanged in version 3.13: On Unix, Free threading Python installations are identified by the “t” suffix in the\r\nversion-specific directory name, such as lib/python3.13t/ .\r\nWhen running under a virtual environment, the pyvenv.cfg file in sys.prefix is checked for site-specific\r\nconfigurations. If the include-system-site-packages key exists and is set to true (case-insensitive), the\r\nsystem-level prefixes will be searched for site-packages, otherwise they won’t.\r\nA path configuration file is a file whose name has the form name.pth and exists in one of the four directories\r\nmentioned above; its contents are additional items (one per line) to be added to sys.path . Non-existing items are\r\nnever added to sys.path , and no check is made that the item refers to a directory rather than a file. No item is\r\nadded to sys.path more than once. Blank lines and lines beginning with # are skipped. Lines starting with\r\nimport (followed by space or tab) are executed.\r\nNote\r\nAn executable line in a .pth file is run at every Python startup, regardless of whether a particular module is\r\nactually going to be used. Its impact should thus be kept to a minimum. The primary intended purpose of\r\nexecutable lines is to make the corresponding module(s) importable (load 3rd-party import hooks, adjust PATH\r\nhttps://docs.python.org/3/library/site.html\r\nPage 1 of 5\n\netc). Any other initialization is supposed to be done upon a module’s actual import, if and when it happens.\r\nLimiting a code chunk to a single line is a deliberate measure to discourage putting anything more complex here.\r\nChanged in version 3.13: The .pth files are now decoded by UTF-8 at first and then by the locale encoding if it\r\nfails.\r\nFor example, suppose sys.prefix and sys.exec_prefix are set to /usr/local . The Python X.Y library is\r\nthen installed in /usr/local/lib/pythonX.Y . Suppose this has a subdirectory /usr/local/lib/pythonX.Y/site-packages with three subsubdirectories, foo , bar and spam , and two path configuration files, foo.pth and\r\nbar.pth . Assume foo.pth contains the following:\r\n# foo package configuration\r\nfoo\r\nbar\r\nbletch\r\nand bar.pth contains:\r\n# bar package configuration\r\nbar\r\nThen the following version-specific directories are added to sys.path , in this order:\r\n/usr/local/lib/pythonX.Y/site-packages/bar\r\n/usr/local/lib/pythonX.Y/site-packages/foo\r\nNote that bletch is omitted because it doesn’t exist; the bar directory precedes the foo directory because\r\nbar.pth comes alphabetically before foo.pth ; and spam is omitted because it is not mentioned in either path\r\nconfiguration file.\r\nsitecustomize ¶\r\nAfter these path manipulations, an attempt is made to import a module named sitecustomize , which can\r\nperform arbitrary site-specific customizations. It is typically created by a system administrator in the site-packages\r\ndirectory. If this import fails with an ImportError or its subclass exception, and the exception’s name attribute\r\nequals 'sitecustomize' , it is silently ignored. If Python is started without output streams available, as with\r\npythonw.exe on Windows (which is used by default to start IDLE), attempted output from sitecustomize is\r\nignored. Any other exception causes a silent and perhaps mysterious failure of the process.\r\nusercustomize ¶\r\nhttps://docs.python.org/3/library/site.html\r\nPage 2 of 5\n\nAfter this, an attempt is made to import a module named usercustomize , which can perform arbitrary user-specific customizations, if ENABLE_USER_SITE is true. This file is intended to be created in the user site-packages\r\ndirectory (see below), which is part of sys.path unless disabled by -s . If this import fails with an\r\nImportError or its subclass exception, and the exception’s name attribute equals 'usercustomize' , it is\r\nsilently ignored.\r\nNote that for some non-Unix systems, sys.prefix and sys.exec_prefix are empty, and the path manipulations\r\nare skipped; however the import of sitecustomize and usercustomize is still attempted.\r\nReadline configuration¶\r\nOn systems that support readline , this module will also import and configure the rlcompleter module, if\r\nPython is started in interactive mode and without the -S option. The default behavior is to enable tab completion\r\nand to use ~/.python_history as the history save file. To disable it, delete (or override) the\r\nsys.__interactivehook__ attribute in your sitecustomize or usercustomize module or your\r\nPYTHONSTARTUP file.\r\nChanged in version 3.4: Activation of rlcompleter and history was made automatic.\r\nModule contents¶\r\nsite.PREFIXES¶\r\nA list of prefixes for site-packages directories.\r\nsite.ENABLE_USER_SITE¶\r\nFlag showing the status of the user site-packages directory. True means that it is enabled and was added\r\nto sys.path . False means that it was disabled by user request (with -s or PYTHONNOUSERSITE ).\r\nNone means it was disabled for security reasons (mismatch between user or group id and effective id) or\r\nby an administrator.\r\nsite.USER_SITE¶\r\nPath to the user site-packages for the running Python. Can be None if getusersitepackages() hasn’t\r\nbeen called yet. Default value is ~/.local/lib/pythonX.Y[t]/site-packages for UNIX and non-framework macOS builds, ~/Library/Python/X.Y/lib/python/site-packages for macOS framework\r\nbuilds, and %APPDATA%\\Python\\PythonXY\\site-packages on Windows. The optional “t” indicates the free-threaded build. This directory is a site directory, which means that .pth files in it will be processed.\r\nsite.USER_BASE¶\r\nPath to the base directory for the user site-packages. Can be None if getuserbase() hasn’t been called\r\nyet. Default value is ~/.local for UNIX and macOS non-framework builds, ~/Library/Python/X.Y for\r\nmacOS framework builds, and %APPDATA%\\Python for Windows. This value is used to compute the\r\nhttps://docs.python.org/3/library/site.html\r\nPage 3 of 5\n\ninstallation directories for scripts, data files, Python modules, etc. for the user installation scheme. See also\r\nPYTHONUSERBASE .\r\nsite.main()¶\r\nAdds all the standard site-specific directories to the module search path. This function is called\r\nautomatically when this module is imported, unless the Python interpreter was started with the -S flag.\r\nChanged in version 3.3: This function used to be called unconditionally.\r\nsite.addsitedir(sitedir, known_paths=None)¶\r\nAdd a directory to sys.path and process its .pth files. Typically used in sitecustomize or\r\nusercustomize (see above).\r\nsite.getsitepackages()¶\r\nReturn a list containing all global site-packages directories.\r\nAdded in version 3.2.\r\nsite.getuserbase()¶\r\nReturn the path of the user base directory, USER_BASE . If it is not initialized yet, this function will also set\r\nit, respecting PYTHONUSERBASE .\r\nAdded in version 3.2.\r\nsite.getusersitepackages()¶\r\nReturn the path of the user-specific site-packages directory, USER_SITE . If it is not initialized yet, this\r\nfunction will also set it, respecting USER_BASE . To determine if the user-specific site-packages was added\r\nto sys.path ENABLE_USER_SITE should be used.\r\nAdded in version 3.2.\r\nCommand-line interface¶\r\nThe site module also provides a way to get the user directories from the command line:\r\n$ python -m site --user-site\r\n/home/user/.local/lib/python3.11/site-packages\r\nIf it is called without arguments, it will print the contents of sys.path on the standard output, followed by the\r\nvalue of USER_BASE and whether the directory exists, then the same thing for USER_SITE , and finally the value\r\nof ENABLE_USER_SITE .\r\n--user-base¶\r\nhttps://docs.python.org/3/library/site.html\r\nPage 4 of 5\n\nPrint the path to the user base directory.\r\n--user-site¶\r\nPrint the path to the user site-packages directory.\r\nIf both options are given, user base and user site will be printed (always in this order), separated by os.pathsep .\r\nIf any option is given, the script will exit with one of these values: 0 if the user site-packages directory is\r\nenabled, 1 if it was disabled by the user, 2 if it is disabled for security reasons or by an administrator, and a\r\nvalue greater than 2 if there is an error.\r\nSee also\r\nPEP 370 – Per user site-packages directory\r\nThe initialization of the sys.path module search path – The initialization of sys.path .\r\nSource: https://docs.python.org/3/library/site.html\r\nhttps://docs.python.org/3/library/site.html\r\nPage 5 of 5",
	"extraction_quality": 1,
	"language": "EN",
	"sources": [
		"MITRE"
	],
	"origins": [
		"web"
	],
	"references": [
		"https://docs.python.org/3/library/site.html"
	],
	"report_names": [
		"site.html"
	],
	"threat_actors": [],
	"ts_created_at": 1775434565,
	"ts_updated_at": 1775826727,
	"ts_creation_date": 0,
	"ts_modification_date": 0,
	"files": {
		"pdf": "https://archive.orkl.eu/e35b1e921b19ba7e9250521add8431b3293c1775.pdf",
		"text": "https://archive.orkl.eu/e35b1e921b19ba7e9250521add8431b3293c1775.txt",
		"img": "https://archive.orkl.eu/e35b1e921b19ba7e9250521add8431b3293c1775.jpg"
	}
}