From 667426dc0900d8142e221dbf360da1568e033405 Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <github@naumov.de>
Date: Sat, 3 Nov 2018 23:38:58 +0100
Subject: [PATCH] [App] Add project dir to python module path.

When the python modules are not in the current working directory but
in the projects directory, the user modules would not be found.
Adding project's directory to the python's module path allows to run ogs
from a different directory than the project file.
---
 Applications/ApplicationsLib/ProjectData.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Applications/ApplicationsLib/ProjectData.cpp b/Applications/ApplicationsLib/ProjectData.cpp
index 5fe229eae8c..6c4950e9202 100644
--- a/Applications/ApplicationsLib/ProjectData.cpp
+++ b/Applications/ApplicationsLib/ProjectData.cpp
@@ -200,6 +200,11 @@ ProjectData::ProjectData(BaseLib::ConfigTree const& project_config,
     {
 #ifdef OGS_USE_PYTHON
         namespace py = pybind11;
+
+        // Append project's directory to python's module search path.
+        py::module::import("sys").attr("path").attr("append")(
+            project_directory);
+
         auto const script_path =
             BaseLib::copyPathToFileName(*python_script, project_directory);
 
-- 
GitLab