diff --git a/src/pymod/unit_tests/pymod_tests.cc b/src/pymod/unit_tests/pymod_tests.cc index 88cc5d7f4..3a5887407 100644 --- a/src/pymod/unit_tests/pymod_tests.cc +++ b/src/pymod/unit_tests/pymod_tests.cc @@ -20,6 +20,11 @@ */ +#include "tlUnitTest.h" +#include "tlStream.h" +#include "tlFileUtils.h" +#include "tlEnv.h" + // Oh my god ... STRINGIFY(s) will get the argument with MACROS REPLACED. // So if the PYTHONPATH is something like build.linux-released, the "linux" macro // set to 1 will make this "build.1-release". So STRINGIFY isn't a real solution. @@ -30,22 +35,11 @@ #define STRINGIFY(s) _STRINGIFY(s) #define _STRINGIFY(s) #s -#include "tlUnitTest.h" -#include "tlStream.h" - int run_pymodtest (tl::TestBase *_this, const std::string &fn) { - static std::string pypath; - if (pypath.empty ()) { - pypath = "PYTHONPATH="; - pypath += STRINGIFY (PYTHONPATH); - } -#if defined(_WIN32) - _putenv (const_cast (pypath.c_str ())); -#else - putenv (const_cast (pypath.c_str ())); -#endif - tl::info << pypath; + static std::string pypath = tl::combine_path (tl::get_inst_path (), "pymod"); + tl::info << "PYTHONPATH=" << pypath; + tl::set_env ("PYTHONPATH", pypath); std::string fp (tl::testdata ()); fp += "/pymod/"; diff --git a/src/pymod/unit_tests/unit_tests.pro b/src/pymod/unit_tests/unit_tests.pro index 63ff2f443..b01660775 100644 --- a/src/pymod/unit_tests/unit_tests.pro +++ b/src/pymod/unit_tests/unit_tests.pro @@ -14,20 +14,14 @@ msvc { # "\\\\" is actually *one* backslash for replacement string and *two* backslashes in the # substitution string in qmake ... so we replace \ by \\ here: PYTHON_ESCAPED = $$replace(PYTHON, "\\\\", "\\\\") - PYTHONPATH = $$shell_path($$DESTDIR_UT/pymod) - PYTHONPATH_ESCAPED = $$replace(PYTHONPATH, "\\\\", "\\\\") QMAKE_CXXFLAGS += \ - "-DPYTHON=\"$$PYTHON_ESCAPED\"" \ - "-DPYTHONPATH=\"$$PYTHONPATH_ESCAPED\"" + "-DPYTHON=\"$$PYTHON_ESCAPED\"" } else { - PYTHONPATH = $$DESTDIR_UT/pymod - DEFINES += \ PYTHON=$$PYTHON \ - PYTHONPATH=$$PYTHONPATH } diff --git a/src/tl/tl/tlFileUtils.cc b/src/tl/tl/tlFileUtils.cc index 2541a63ea..74d0ba77d 100644 --- a/src/tl/tl/tlFileUtils.cc +++ b/src/tl/tl/tlFileUtils.cc @@ -908,11 +908,11 @@ get_inst_path () std::string get_exe_file () { - static std::string s_inst_path; - if (s_inst_path.empty ()) { - s_inst_path = tl::absolute_file_path (get_inst_path_internal ()); + static std::string s_exe_file; + if (s_exe_file.empty ()) { + s_exe_file = tl::absolute_file_path (get_inst_path_internal ()); } - return s_inst_path; + return s_exe_file; } std::string