From 9bf3866e8fdf5893d3ba15aca14aa1cac0b82948 Mon Sep 17 00:00:00 2001
From: Luc Papeleux <L.Papeleux@ULiege.be>
Date: Tue, 26 Nov 2024 17:30:30 +0100
Subject: [PATCH] rename configLDLIBRARYPATH in config_ld_library_path

---
 externalProgramPath.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/externalProgramPath.py b/externalProgramPath.py
index 5380eb4..9830f3c 100755
--- a/externalProgramPath.py
+++ b/externalProgramPath.py
@@ -2,6 +2,9 @@
 # -*- coding: utf-8 -*-
 #
 # Define external program paths according to local configuration
+#
+# under linux, call config_ld_library_path(key) to extend LD_LIBRARY_PATH to be able to find .so
+# 
 
 from prmClasses import *
 import os, os.path, shutil #, distutils.spawn
@@ -113,15 +116,14 @@ class ExtProgs(PRMSet):
         SaveAction(self.actions , 'S')
         QuitAction(self.actions , 'Q')
 
-    def configLDLIBRARYPATH(self, key):
+    def config_ld_library_path(self, key): # add progPath/bin/../lib to LD_LIBRARY_PATH (else may not found .so)
         progLibPath = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(self.pars[key].val)),'..','lib'))
-        if os.path.exist(progLibPath):      
+        if os.path.exists(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
+                if os.path.exists(p) and 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']
-        
+                os.environ['LD_LIBRARY_PATH'] = progLibPath + ':' + os.environ['LD_LIBRARY_PATH']                           
 #=================================================================================
 def main():
     progsConf = ExtProgs() #verb=True)
-- 
GitLab