From 6e20c06054c162840d6689eb3d9354dffdf81502 Mon Sep 17 00:00:00 2001
From: Andre Sailer <andre.philippe.sailer@cern.ch>
Date: Tue, 13 Aug 2019 11:36:55 +0200
Subject: [PATCH] Python: export DYLD_LIBRARY_PATH when loading dd4hep or ddg4
 on macos

---
 DDCore/python/dd4hep_base.py | 3 ++-
 DDG4/python/DDG4.py          | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/DDCore/python/dd4hep_base.py b/DDCore/python/dd4hep_base.py
index 7e08680d3..708373be8 100644
--- a/DDCore/python/dd4hep_base.py
+++ b/DDCore/python/dd4hep_base.py
@@ -46,7 +46,8 @@ def loaddd4hep():
   import platform
   if platform.system()=="Darwin":
     gSystem.SetDynamicPath(os.environ['DD4HEP_LIBRARY_PATH'])
-
+    os.environ['DYLD_LIBRARY_PATH'] = os.pathsep.join([os.environ['DD4HEP_LIBRARY_PATH'],
+                                                       os.environ.get('DYLD_LIBRARY_PATH', '')]).strip(os.pathsep)
   result = gSystem.Load("libDDCore")
   if result < 0:
     raise Exception('dd4hep.py: Failed to load the dd4hep library libDDCore: '+gSystem.GetErrorStr())
diff --git a/DDG4/python/DDG4.py b/DDG4/python/DDG4.py
index 59053cc9a..00f37b3f2 100644
--- a/DDG4/python/DDG4.py
+++ b/DDG4/python/DDG4.py
@@ -27,6 +27,8 @@ def loadDDG4():
   import os
   if platform.system()=="Darwin":
     gSystem.SetDynamicPath(os.environ['DD4HEP_LIBRARY_PATH'])
+    os.environ['DYLD_LIBRARY_PATH'] = os.pathsep.join([os.environ['DD4HEP_LIBRARY_PATH'],
+                                                       os.environ.get('DYLD_LIBRARY_PATH', '')]).strip(os.pathsep)
 
   result = gSystem.Load("libDDG4Plugins")
   if result < 0:
-- 
GitLab