MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / addsitedir

Function addsitedir

tools/python-3.11.9-amd64/Lib/site.py:216–239  ·  view source on GitHub ↗

Add 'sitedir' argument to sys.path if missing and handle .pth files in 'sitedir

(sitedir, known_paths=None)

Source from the content-addressed store, hash-verified

214
215
216def addsitedir(sitedir, known_paths=None):
217 """Add 'sitedir' argument to sys.path if missing and handle .pth files in
218 'sitedir'"""
219 _trace(f"Adding directory: {sitedir!r}")
220 if known_paths is None:
221 known_paths = _init_pathinfo()
222 reset = True
223 else:
224 reset = False
225 sitedir, sitedircase = makepath(sitedir)
226 if not sitedircase in known_paths:
227 sys.path.append(sitedir) # Add path component
228 known_paths.add(sitedircase)
229 try:
230 names = os.listdir(sitedir)
231 except OSError:
232 return
233 names = [name for name in names
234 if name.endswith(".pth") and not name.startswith(".")]
235 for name in sorted(names):
236 addpackage(sitedir, name, known_paths)
237 if reset:
238 known_paths = None
239 return known_paths
240
241
242def check_enableusersite():

Callers 2

addusersitepackagesFunction · 0.85
addsitepackagesFunction · 0.85

Calls 10

_traceFunction · 0.85
_init_pathinfoFunction · 0.85
makepathFunction · 0.85
sortedFunction · 0.85
addpackageFunction · 0.85
listdirMethod · 0.80
endswithMethod · 0.80
startswithMethod · 0.80
appendMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected