(self)
| 1517 | api=API_COMPAT, env=env, ignore_stderr=True) |
| 1518 | |
| 1519 | def test_init_is_python_build_with_home(self): |
| 1520 | # Test _Py_path_config._is_python_build configuration (gh-91985) |
| 1521 | config = self._get_expected_config() |
| 1522 | paths = config['config']['module_search_paths'] |
| 1523 | paths_str = os.path.pathsep.join(paths) |
| 1524 | |
| 1525 | for path in paths: |
| 1526 | if not os.path.isdir(path): |
| 1527 | continue |
| 1528 | if os.path.exists(os.path.join(path, 'os.py')): |
| 1529 | home = os.path.dirname(path) |
| 1530 | break |
| 1531 | else: |
| 1532 | self.fail(f"Unable to find home in {paths!r}") |
| 1533 | |
| 1534 | prefix = exec_prefix = home |
| 1535 | if MS_WINDOWS: |
| 1536 | stdlib = os.path.join(home, "Lib") |
| 1537 | # Because we are specifying 'home', module search paths |
| 1538 | # are fairly static |
| 1539 | expected_paths = [paths[0], os.path.join(home, 'DLLs'), stdlib] |
| 1540 | else: |
| 1541 | version = f'{sys.version_info.major}.{sys.version_info.minor}' |
| 1542 | stdlib = os.path.join(home, sys.platlibdir, f'python{version}{ABI_THREAD}') |
| 1543 | expected_paths = self.module_search_paths(prefix=home, exec_prefix=home) |
| 1544 | |
| 1545 | config = { |
| 1546 | 'home': home, |
| 1547 | 'module_search_paths': expected_paths, |
| 1548 | 'prefix': prefix, |
| 1549 | 'base_prefix': prefix, |
| 1550 | 'exec_prefix': exec_prefix, |
| 1551 | 'base_exec_prefix': exec_prefix, |
| 1552 | 'pythonpath_env': paths_str, |
| 1553 | 'stdlib_dir': stdlib, # Only correct on _is_python_build==0! |
| 1554 | } |
| 1555 | # The code above is taken from test_init_setpythonhome() |
| 1556 | env = {'TESTHOME': home, 'PYTHONPATH': paths_str} |
| 1557 | |
| 1558 | env['NEGATIVE_ISPYTHONBUILD'] = '1' |
| 1559 | config['_is_python_build'] = 0 |
| 1560 | # This configuration doesn't set a valid stdlibdir/plststdlibdir because |
| 1561 | # with _is_python_build=0 getpath doesn't check for the build directory |
| 1562 | # landmarks in PYTHONHOME/Py_SetPythonHome. |
| 1563 | # getpath correctly shows a warning, which messes up check_all_configs, |
| 1564 | # so we need to ignore stderr. |
| 1565 | self.check_all_configs("test_init_is_python_build", config, |
| 1566 | api=API_COMPAT, env=env, ignore_stderr=True) |
| 1567 | |
| 1568 | # config['stdlib_dir'] = os.path.join(home, 'Lib') |
| 1569 | # FIXME: This test does not check if stdlib_dir is calculated correctly. |
| 1570 | # test_init_is_python_build runs the initialization twice, |
| 1571 | # setting stdlib_dir in _Py_path_config on the first run, which |
| 1572 | # then overrides the stdlib_dir calculation (as of GH-108730). |
| 1573 | |
| 1574 | env['NEGATIVE_ISPYTHONBUILD'] = '0' |
| 1575 | config['_is_python_build'] = 1 |
| 1576 | exedir = os.path.dirname(sys.executable) |
nothing calls this directly
no test coverage detected