From 55c25dd862ceb5931193cf0d91f783562203d193 Mon Sep 17 00:00:00 2001 From: Tristan Walter <twalter@orn.mpg.de> Date: Thu, 8 Oct 2020 13:32:22 +0200 Subject: [PATCH] trex_build_windows and trying to properly fix run paths --- Application/src/tracker/python/GPURecognition.cpp | 6 +++++- Application/src/tracker/tracking/Recognition.cpp | 10 ++++++++-- Application/trex_build_windows.bat | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Application/src/tracker/python/GPURecognition.cpp b/Application/src/tracker/python/GPURecognition.cpp index fc0f977..9042f2d 100644 --- a/Application/src/tracker/python/GPURecognition.cpp +++ b/Application/src/tracker/python/GPURecognition.cpp @@ -347,7 +347,10 @@ namespace track { if (!getenv("TREX_DONT_SET_PATHS")) { std::string sep = "/"; auto home = Py_GetPythonHome(); - auto home2 = SETTING(python_path).value<file::Path>().remove_filename().str(); + auto home2 = SETTING(python_path).value<file::Path>().str(); + if(file::Path(home2).exists() && file::Path(home2).is_regular()) + home2 = file::Path(home2).remove_filename().str(); + Debug("Setting home to '%S'", &home2); if (!home2.empty()) { home2 = utils::find_replace(home2, "/", sep); @@ -356,6 +359,7 @@ namespace track { wchar_t* pwcsName = new wchar_t[nChars]; MultiByteToWideChar(CP_ACP, 0, home2.c_str(), -1, (LPWSTR)pwcsName, nChars); Py_SetPythonHome(pwcsName); + SetEnvironmentVariable("PYTHONHOME", home2.c_str()); // delete it delete[] pwcsName; diff --git a/Application/src/tracker/tracking/Recognition.cpp b/Application/src/tracker/tracking/Recognition.cpp index ccb1b10..4debfb1 100644 --- a/Application/src/tracker/tracking/Recognition.cpp +++ b/Application/src/tracker/tracking/Recognition.cpp @@ -155,7 +155,10 @@ Image::Ptr Recognition::calculate_diff_image_with_settings(const default_config: #else exec = "./"+exec+" 2> /dev/null"; #endif - + if ((SETTING(wd).value<file::Path>() / exec).exists()) { + exec = (SETTING(wd).value<file::Path>() / exec).str(); + Debug("Exists in working dir: '%S'", &exec); + } auto ret = system(exec.c_str()) == 0; #if WIN32 SetErrorMode(0); @@ -180,7 +183,10 @@ Image::Ptr Recognition::calculate_diff_image_with_settings(const default_config: #ifdef TREX_PYTHON_PATH auto home = ::default_config::conda_environment_path().str(); if (home.empty()) - home = SETTING(python_path).value<file::Path>().remove_filename().str(); + home = SETTING(python_path).value<file::Path>().str(); + if (file::Path(home).exists() && file::Path(home).is_regular()) + home = file::Path(home).remove_filename().str(); + Debug("Setting home to '%S'", &home); if (!can_initialize_python() && !getenv("TREX_DONT_SET_PATHS")) { if (!SETTING(quiet)) diff --git a/Application/trex_build_windows.bat b/Application/trex_build_windows.bat index 7c1c8d1..0df20a6 100644 --- a/Application/trex_build_windows.bat +++ b/Application/trex_build_windows.bat @@ -22,6 +22,6 @@ cmake --build . --target libzip --config Release cmake --build . --target libpng_custom --config Release cmake --build . --target CustomOpenCV --config Release cmake .. -cmake --build . --target INSTALL --config Release +cmake --build . --config Release endlocal \ No newline at end of file -- GitLab