From f483ab6aaf7ebee2fb81d6716118d28434fb5226 Mon Sep 17 00:00:00 2001
From: Luc Papeleux <L.Papeleux@ULiege.be>
Date: Tue, 26 Nov 2024 16:55:17 +0100
Subject: [PATCH] add  configLDLIBRARYPATH function to find .so using install
 version of Metafor

---
 externalProgramPath.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/externalProgramPath.py b/externalProgramPath.py
index f7565f9..5380eb4 100755
--- a/externalProgramPath.py
+++ b/externalProgramPath.py
@@ -91,7 +91,7 @@ class ExtProgs(PRMSet):
             print("\t Use 'externalProgramPathGui' to define the full program path (recommanded)")
             print("\t or add %s in your user path (not recommanded)"%key)
             return False
-
+    
     def configAction(self):
         PRMAction(self.actions, 'a', self.pars['SAMCEF'])
         PRMAction(self.actions, 'b', self.pars['GMSH'])
@@ -113,6 +113,15 @@ class ExtProgs(PRMSet):
         SaveAction(self.actions , 'S')
         QuitAction(self.actions , 'Q')
 
+    def configLDLIBRARYPATH(self, key):
+        progLibPath = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(self.pars[key].val)),'..','lib'))
+        if os.path.exist(progLibPath):      
+            for p in os.environ['LD_LIBRARY_PATH'].split(':'):
+                if os.path.samefile(progLibPath, p): # deja dans le LD_LIBRARY_PATH => on skippe l'ajout
+                    break    
+            else : # pas trouvé dans le LD_LIBRARY_PATH => on ajoute dans le LD_LIBRARY_PATH
+                os.environ['LD_LIBRARY_PATH'] = progLibPath + ':' + os.environ['LD_LIBRARY_PATH']
+        
 #=================================================================================
 def main():
     progsConf = ExtProgs() #verb=True)
-- 
GitLab