(known_paths)
| 593 | |
| 594 | |
| 595 | def venv(known_paths): |
| 596 | global PREFIXES, ENABLE_USER_SITE |
| 597 | |
| 598 | env = os.environ |
| 599 | if sys.platform == 'darwin' and '__PYVENV_LAUNCHER__' in env: |
| 600 | executable = sys._base_executable = os.environ['__PYVENV_LAUNCHER__'] |
| 601 | else: |
| 602 | executable = sys.executable |
| 603 | exe_dir = os.path.dirname(os.path.abspath(executable)) |
| 604 | site_prefix = os.path.dirname(exe_dir) |
| 605 | sys._home = None |
| 606 | conf_basename = 'pyvenv.cfg' |
| 607 | candidate_conf = next( |
| 608 | ( |
| 609 | conffile for conffile in ( |
| 610 | os.path.join(exe_dir, conf_basename), |
| 611 | os.path.join(site_prefix, conf_basename) |
| 612 | ) |
| 613 | if os.path.isfile(conffile) |
| 614 | ), |
| 615 | None |
| 616 | ) |
| 617 | |
| 618 | if candidate_conf: |
| 619 | virtual_conf = candidate_conf |
| 620 | system_site = "true" |
| 621 | # Issue 25185: Use UTF-8, as that's what the venv module uses when |
| 622 | # writing the file. |
| 623 | with open(virtual_conf, encoding='utf-8') as f: |
| 624 | for line in f: |
| 625 | if '=' in line: |
| 626 | key, _, value = line.partition('=') |
| 627 | key = key.strip().lower() |
| 628 | value = value.strip() |
| 629 | if key == 'include-system-site-packages': |
| 630 | system_site = value.lower() |
| 631 | elif key == 'home': |
| 632 | sys._home = value |
| 633 | |
| 634 | if sys.prefix != site_prefix: |
| 635 | _warn(f'Unexpected value in sys.prefix, expected {site_prefix}, got {sys.prefix}', RuntimeWarning) |
| 636 | if sys.exec_prefix != site_prefix: |
| 637 | _warn(f'Unexpected value in sys.exec_prefix, expected {site_prefix}, got {sys.exec_prefix}', RuntimeWarning) |
| 638 | |
| 639 | # Doing this here ensures venv takes precedence over user-site |
| 640 | addsitepackages(known_paths, [sys.prefix]) |
| 641 | |
| 642 | if system_site == "true": |
| 643 | PREFIXES += [sys.base_prefix, sys.base_exec_prefix] |
| 644 | else: |
| 645 | ENABLE_USER_SITE = False |
| 646 | |
| 647 | return known_paths |
| 648 | |
| 649 | |
| 650 | def execsitecustomize(): |
no test coverage detected
searching dependent graphs…