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

Function venv

tools/python-3.11.9-amd64/Lib/site.py:502–551  ·  view source on GitHub ↗
(known_paths)

Source from the content-addressed store, hash-verified

500 sys.__interactivehook__ = register_readline
501
502def venv(known_paths):
503 global PREFIXES, ENABLE_USER_SITE
504
505 env = os.environ
506 if sys.platform == 'darwin' and '__PYVENV_LAUNCHER__' in env:
507 executable = sys._base_executable = os.environ['__PYVENV_LAUNCHER__']
508 else:
509 executable = sys.executable
510 exe_dir, _ = os.path.split(os.path.abspath(executable))
511 site_prefix = os.path.dirname(exe_dir)
512 sys._home = None
513 conf_basename = 'pyvenv.cfg'
514 candidate_confs = [
515 conffile for conffile in (
516 os.path.join(exe_dir, conf_basename),
517 os.path.join(site_prefix, conf_basename)
518 )
519 if os.path.isfile(conffile)
520 ]
521
522 if candidate_confs:
523 virtual_conf = candidate_confs[0]
524 system_site = "true"
525 # Issue 25185: Use UTF-8, as that's what the venv module uses when
526 # writing the file.
527 with open(virtual_conf, encoding='utf-8') as f:
528 for line in f:
529 if '=' in line:
530 key, _, value = line.partition('=')
531 key = key.strip().lower()
532 value = value.strip()
533 if key == 'include-system-site-packages':
534 system_site = value.lower()
535 elif key == 'home':
536 sys._home = value
537
538 sys.prefix = sys.exec_prefix = site_prefix
539
540 # Doing this here ensures venv takes precedence over user-site
541 addsitepackages(known_paths, [sys.prefix])
542
543 # addsitepackages will process site_prefix again if its in PREFIXES,
544 # but that's ok; known_paths will prevent anything being added twice
545 if system_site == "true":
546 PREFIXES.insert(0, sys.prefix)
547 else:
548 PREFIXES = [sys.prefix]
549 ENABLE_USER_SITE = False
550
551 return known_paths
552
553
554def execsitecustomize():

Callers 1

mainFunction · 0.85

Calls 9

addsitepackagesFunction · 0.85
partitionMethod · 0.80
stripMethod · 0.80
openFunction · 0.70
splitMethod · 0.45
joinMethod · 0.45
isfileMethod · 0.45
lowerMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected