Skip to content

Commit

Permalink
Fix tests by using PYTHONPATH if no paths specified when initializing…
Browse files Browse the repository at this point in the history
… runner.
  • Loading branch information
Holt59 committed Jun 1, 2024
1 parent 1ab4dbe commit 86f173f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/runner/pythonrunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,19 @@ namespace mo2::python {
// initialize the core Path of Python, this must be done before
// initialization
//
// TODO: use config.module_search_paths, config.module_search_paths_set and
// config.pythonpath_env instead of Py_SetPath
//
if (!pythonPaths.empty()) {
QStringList paths;
for (auto const& p : pythonPaths) {
paths.append(QString::fromStdWString(absolute(p).native()));
}
Py_SetPath(paths.join(';').toStdWString().c_str());
}
else if (auto* pythonPathEnv = _wgetenv(L"PYTHONPATH")) {
Py_SetPath(pythonPathEnv);
}

PyConfig config;
PyConfig_InitIsolatedConfig(&config);
Expand Down
4 changes: 2 additions & 2 deletions tests/runner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ string(APPEND extra_paths "\\;${PYTHON_ROOT}/PCbuild/amd64")
string(APPEND extra_paths "\\;$<TARGET_FILE_DIR:runner>")
set_tests_properties(${runner-tests_gtests}
PROPERTIES
WORKING_DIRECTORY "${MO2_INSTALL_PATH}/bin"
ENVIRONMENT "PLUGIN_DIR=${CMAKE_CURRENT_SOURCE_DIR}/plugins"
ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:${extra_paths};PYTHONPATH=set:${PYTHONPATH}")
"PATH=path_list_prepend:${extra_paths};PYTHONPATH=set:${PYTHONPATH}"
)

0 comments on commit 86f173f

Please sign in to comment.