From a5c5f3bc72837a573d1f3a189fff7c582449f771 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 13 Sep 2013 14:09:32 +0000 Subject: [PATCH] adding path of gmsh binary to PATH --- Common/GmshMessage.cpp | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index 82ff04fbaf..fdaceec11d 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -78,6 +78,24 @@ static int vsnprintf(char *str, size_t size, const char *fmt, va_list ap) #define vsnprintf _vsnprintf #endif +static void addGmshPathToEnvironmentVar(const std::string &name) +{ + std::vector<std::string> split = SplitFileName(CTX::instance()->argv0); + std::string path; + char *tmp = getenv(name.c_str()); + if(tmp){ + path = tmp; +#if defined(WIN32) + path += ";" + split[0]; +#else + path += ":" + split[0]; +#endif + } + else + path = split[0]; + SetEnvironmentVar(name.c_str(), path.c_str()); +} + void Msg::Init(int argc, char **argv) { #if defined(HAVE_MPI) @@ -116,23 +134,10 @@ void Msg::Init(int argc, char **argv) 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; -#if defined(WIN32) - path += ";" + split[0]; -#else - path += ":" + split[0]; -#endif - } - else - path = split[0]; - SetEnvironmentVar("PYTHONPATH", path.c_str()); + addGmshPathToEnvironmentVar("PYTHONPATH"); + addGmshPathToEnvironmentVar("PATH"); } InitializeOnelab("Gmsh"); -- GitLab