17
17
#include " OSDependent/omnisci_path.h"
18
18
19
19
#include < boost/filesystem/path.hpp>
20
+ #include < filesystem>
20
21
21
22
#include " Logger/Logger.h"
22
23
@@ -31,10 +32,23 @@ std::string get_root_abs_path() {
31
32
CHECK_LT (static_cast <size_t >(path_len), sizeof (abs_exe_path));
32
33
boost::filesystem::path abs_exe_dir (std::string (abs_exe_path, path_len));
33
34
abs_exe_dir.remove_filename ();
34
- // account for build type dir (e.g. Release)
35
- const auto mapd_root = abs_exe_dir.parent_path ().parent_path ();
36
-
37
- return mapd_root.string ();
35
+ // When installed in conda env the path points python.exe that is located
36
+ // in the root of conda environment.
37
+ // When running tests in built repo the path points to omniscidb\Tests\{Debug|Release}\
38
+ // which is three levels below "bin" directory with calcite jar file.
39
+ // Because of this disbalance we try to look up QueryEngine/RuntimeFunctions.bc file.
40
+ // QueryEngine is located either one level below "bin" or on the same level. When it is
41
+ // below "bin" then this one more up level is done in CalciteJNI.
42
+ const int UP_PATH_LEVELS = 2 ;
43
+ for (int up_levels = 0 ; up_levels <= UP_PATH_LEVELS; up_levels++) {
44
+ std::string target_path = abs_exe_dir.string () + " /QueryEngine/RuntimeFunctions.bc" ;
45
+ if (std::filesystem::exists (target_path)) {
46
+ break ;
47
+ }
48
+ abs_exe_dir = abs_exe_dir.parent_path ();
49
+ }
50
+
51
+ return abs_exe_dir.string ();
38
52
}
39
53
40
54
} // namespace omnisci
0 commit comments