static _PyInitError calculate_path_impl(const _PyCoreConfig *core_config, PyCalculatePath *calculate, _PyPathConfig *config) { _PyInitError err; err = calculate_program_full_path(core_config, calculate, config); if (_Py_INIT_FAILED(err)) { return err; } err = calculate_argv0_path(calculate, config->program_full_path); if (_Py_INIT_FAILED(err)) { return err; } calculate_read_pyenv(calculate); wchar_t prefix[MAXPATHLEN+1]; memset(prefix, 0, sizeof(prefix)); calculate_prefix(core_config, calculate, prefix); calculate_zip_path(calculate, prefix); wchar_t exec_prefix[MAXPATHLEN+1]; memset(exec_prefix, 0, sizeof(exec_prefix)); calculate_exec_prefix(core_config, calculate, exec_prefix); if ((!calculate->prefix_found || !calculate->exec_prefix_found) && !core_config->_frozen) { fprintf(stderr, "Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]\n"); } err = calculate_module_search_path(core_config, calculate, prefix, exec_prefix, config); if (_Py_INIT_FAILED(err)) { return err; } calculate_reduce_prefix(calculate, prefix); config->prefix = _PyMem_RawWcsdup(prefix); if (config->prefix == NULL) { return _Py_INIT_NO_MEMORY(); } calculate_reduce_exec_prefix(calculate, exec_prefix); config->exec_prefix = _PyMem_RawWcsdup(exec_prefix); if (config->exec_prefix == NULL) { return _Py_INIT_NO_MEMORY(); } return _Py_INIT_OK(); }
static _PyInitError calculate_path_impl(const _PyCoreConfig *core_config, PyCalculatePath *calculate, _PyPathConfig *config) { _PyInitError err; err = get_dll_path(calculate, config); if (_Py_INIT_FAILED(err)) { return err; } err = get_program_full_path(core_config, calculate, config); if (_Py_INIT_FAILED(err)) { return err; } /* program_full_path guaranteed \0 terminated in MAXPATH+1 bytes. */ wcscpy_s(calculate->argv0_path, MAXPATHLEN+1, config->program_full_path); reduce(calculate->argv0_path); wchar_t prefix[MAXPATHLEN+1]; memset(prefix, 0, sizeof(prefix)); /* Search for a sys.path file */ if (calculate_pth_file(config, prefix)) { goto done; } calculate_pyvenv_file(calculate); /* Calculate zip archive path from DLL or exe path */ change_ext(calculate->zip_path, config->dll_path[0] ? config->dll_path : config->program_full_path, L".zip"); calculate_home_prefix(calculate, prefix); err = calculate_module_search_path(core_config, calculate, config, prefix); if (_Py_INIT_FAILED(err)) { return err; } done: config->prefix = _PyMem_RawWcsdup(prefix); if (config->prefix == NULL) { return _Py_INIT_NO_MEMORY(); } return _Py_INIT_OK(); }