diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp index f6fcdbb4bc641d2fd7b42c2faf9c4b9356ac14d4..c13ac7d76a616b6efb3325a303d3b1bb60828aa0 100644 --- a/Common/CommandLine.cpp +++ b/Common/CommandLine.cpp @@ -268,7 +268,6 @@ void GetOptions(int argc, char *argv[]) #if defined(HAVE_PARSER) if(argc && argv){ - CTX::instance()->argv0 = std::string(argv[0]); // parse session and option file (if argc/argv is not provided skip this // step: this is usually what is expected when using Gmsh as a library) ParseFile(CTX::instance()->homeDir + CTX::instance()->sessionFileName, true); diff --git a/Common/Context.cpp b/Common/Context.cpp index a01f59324739fc156a4da29dc9056c408c091be2..e590c67d9e7e33173358fe754f68045d7c6e1170 100644 --- a/Common/Context.cpp +++ b/Common/Context.cpp @@ -59,9 +59,7 @@ CTX::CTX() : gamepad(0) post.draw = 1; post.combineTime = 0; // try to combineTime views at startup lock = 0; // very primitive locking - /// fileread=false; - /// #if defined(HAVE_FLTK) glFontEnum = FL_HELVETICA; diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index 7628c9cbd06d369e1f7c50f4e6466128538cf758..d0d44dbca2b32dcda99008a258b4e2329aa7f0b9 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -17,6 +17,7 @@ #include "Options.h" #include "Context.h" #include "OpenFile.h" +#include "StringUtils.h" #include "OS.h" #if defined(HAVE_ONELAB) @@ -112,6 +113,25 @@ void Msg::Init(int argc, char **argv) if(i) _commandLine += " "; _commandLine += argv[i]; } + + if(argc && argv){ + CTX::instance()->argv0 = std::string(argv[0]); + std::vector<std::string> split = SplitFileName(CTX::instance()->argv0); + + // add the directory where the binary is installed to the path where Python + // looks for modules + std::string path; + char *tmp = getenv("PYTHONPATH"); + if(tmp){ + path = tmp; + path += ":" + split[0]; + } + else + path = split[0]; + setenv("PYTHONPATH", path.c_str(), 1); + printf("pythonpath = %s\n", path.c_str()); + } + InitializeOnelab("Gmsh"); }