MS_WINDOWS = (os.name == 'nt')
+MACOS = (sys.platform == 'darwin')
PYMEM_ALLOCATOR_NOT_SET = 0
PYMEM_ALLOCATOR_DEBUG = 2
executable = self.test_exe
else:
program_name = 'python3'
- executable = shutil.which(program_name) or ''
+ if MACOS:
+ executable = self.test_exe
+ else:
+ executable = shutil.which(program_name) or ''
config.update({
'program_name': program_name,
'base_executable': executable,
'executable': 'conf_executable',
}
env = {'TESTPATH': os.path.pathsep.join(paths)}
- # Py_SetPath() preinitialized Python using the compat API,
- # so we need preconfig_api=API_COMPAT.
self.check_all_configs("test_init_setpath_config", config,
- api=API_PYTHON,
- preconfig_api=API_COMPAT,
- env=env,
- ignore_stderr=True)
+ api=API_PYTHON, env=env, ignore_stderr=True)
def module_search_paths(self, prefix=None, exec_prefix=None):
config = self._get_expected_config()
static int test_init_setpath_config(void)
{
+ PyStatus status;
+ PyPreConfig preconfig;
+ PyPreConfig_InitPythonConfig(&preconfig);
+
+ /* Explicitly preinitializes with Python preconfiguration to avoid
+ Py_SetPath() implicit preinitialization with compat preconfiguration. */
+ status = Py_PreInitialize(&preconfig);
+ if (PyStatus_Exception(status)) {
+ Py_ExitStatusException(status);
+ }
+
char *env = getenv("TESTPATH");
if (!env) {
fprintf(stderr, "missing TESTPATH env var\n");
PyMem_RawFree(path);
putenv("TESTPATH=");
- PyStatus status;
PyConfig config;
status = PyConfig_InitPythonConfig(&config);