summaryrefslogtreecommitdiffstats
path: root/Lib/site.py
diff options
context:
space:
mode:
authornative-api <vano@mail.mipt.ru>2020-06-12 06:20:11 (GMT)
committerGitHub <noreply@github.com>2020-06-12 06:20:11 (GMT)
commit2145c8c9724287a310bc77a2760d4f1c0ca9eb0c (patch)
tree754c3c52598209ebfd547710d0736e2ac01351ac /Lib/site.py
parentddef3bdc7b254a7e1129a52c17d79cb7c73a88f5 (diff)
downloadcpython-2145c8c9724287a310bc77a2760d4f1c0ca9eb0c.zip
cpython-2145c8c9724287a310bc77a2760d4f1c0ca9eb0c.tar.gz
cpython-2145c8c9724287a310bc77a2760d4f1c0ca9eb0c.tar.bz2
bpo-33944: site: Add site-packages tracing in verbose mode (GH-12110)
Diffstat (limited to 'Lib/site.py')
-rw-r--r--Lib/site.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/site.py b/Lib/site.py
index e981a14..544306c 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -88,6 +88,11 @@ USER_SITE = None
USER_BASE = None
+def _trace(message):
+ if sys.flags.verbose:
+ print(message, file=sys.stderr)
+
+
def makepath(*paths):
dir = os.path.join(*paths)
try:
@@ -156,6 +161,7 @@ def addpackage(sitedir, name, known_paths):
else:
reset = False
fullname = os.path.join(sitedir, name)
+ _trace(f"Processing .pth file: {fullname!r}")
try:
f = io.TextIOWrapper(io.open_code(fullname))
except OSError:
@@ -190,6 +196,7 @@ def addpackage(sitedir, name, known_paths):
def addsitedir(sitedir, known_paths=None):
"""Add 'sitedir' argument to sys.path if missing and handle .pth files in
'sitedir'"""
+ _trace(f"Adding directory: {sitedir!r}")
if known_paths is None:
known_paths = _init_pathinfo()
reset = True
@@ -310,6 +317,7 @@ def addusersitepackages(known_paths):
"""
# get the per user site-package path
# this call will also make sure USER_BASE and USER_SITE are set
+ _trace("Processing user site-packages")
user_site = getusersitepackages()
if ENABLE_USER_SITE and os.path.isdir(user_site):
@@ -354,6 +362,7 @@ def getsitepackages(prefixes=None):
def addsitepackages(known_paths, prefixes=None):
"""Add site-packages to sys.path"""
+ _trace("Processing global site-packages")
for sitedir in getsitepackages(prefixes):
if os.path.isdir(sitedir):
addsitedir(sitedir, known_paths)