diff --git a/src/xrayphysics.py b/src/xrayphysics.py index c080cfc..8fcfa32 100644 --- a/src/xrayphysics.py +++ b/src/xrayphysics.py @@ -14,6 +14,68 @@ def __init__(self, lib_dir=""): else: current_dir = os.path.abspath(os.path.dirname(__file__)) + #''' + if _platform == "linux" or _platform == "linux2": + import readline + from ctypes import cdll + + fullPath = os.path.join(current_dir, 'libxrayphysics.so') + fullPath_backup = os.path.join(current_dir, '../build/lib/libxrayphysics.so') + + if os.path.isfile(fullPath): + self.libxrayphysics = cdll.LoadLibrary(fullPath) + elif os.path.isfile(fullPath_backup): + self.libxrayphysics = cdll.LoadLibrary(fullPath_backup) + else: + print('Error: could not find LEAP dynamic library at') + print(fullPath) + print('or') + print(fullPath_backup) + self.libxrayphysics = None + + elif _platform == "win32": + from ctypes import windll + + fullPath = os.path.join(current_dir, 'libxrayphysics.dll') + fullPath_backup = os.path.join(current_dir, r'..\win_build\bin\Release\libxrayphysics.dll') + + if os.path.isfile(fullPath): + try: + self.libxrayphysics = windll.LoadLibrary(fullPath) + except: + self.libxrayphysics = ctypes.CDLL(fullPath, winmode=0) + elif os.path.isfile(fullPath_backup): + try: + self.libxrayphysics = windll.LoadLibrary(fullPath_backup) + except: + self.libxrayphysics = ctypes.CDLL(fullPath_backup, winmode=0) + else: + print('Error: could not find LEAP dynamic library at') + print(fullPath) + print('or') + print(fullPath_backup) + self.libxrayphysics = None + + elif _platform == "darwin": # Darwin is the name for MacOS in Python's platform module + # there is current no support for LEAP on Mac, but maybe someone can figure this out + from ctypes import cdll + + fullPath = os.path.join(current_dir, 'libxrayphysics.dylib') + fullPath_backup = os.path.join(current_dir, '../build/lib/libxrayphysics.dylib') + + if os.path.isfile(fullPath): + self.libxrayphysics = cdll.LoadLibrary(fullPath) + elif os.path.isfile(fullPath_backup): + self.libxrayphysics = cdll.LoadLibrary(fullPath_backup) + else: + print('Error: could not find LEAP dynamic library at') + print(fullPath) + print('or') + print(fullPath_backup) + self.libxrayphysics = None + #''' + + ''' if _platform == "linux" or _platform == "linux2": import readline from ctypes import cdll @@ -25,6 +87,7 @@ def __init__(self, lib_dir=""): from ctypes import cdll # Adjust the path to where your .dylib file is located self.libxrayphysics = cdll.LoadLibrary(os.path.join(current_dir, "../build/lib/libxrayphysics.dylib")) + #''' self.detectorBits = 16 self.length_units = 'cm'