lib extension for Mac Os X

This commit is contained in:
Jan Janßen 2019-02-04 09:23:29 +01:00
parent 7c2a61ad4c
commit b9d8b5f501
1 changed files with 9 additions and 4 deletions

View File

@ -85,14 +85,19 @@ class lammps(object):
# fall back to loading with a relative path,
# typically requires LD_LIBRARY_PATH to be set appropriately
if sys.platform == 'darwin':
lib_ext = ".dylib"
else:
lib_ext = ".so"
if not self.lib:
try:
if not name: self.lib = CDLL(join(modpath,"liblammps.so"),RTLD_GLOBAL)
else: self.lib = CDLL(join(modpath,"liblammps_%s.so" % name),
if not name: self.lib = CDLL(join(modpath,"liblammps" + lib_ext),RTLD_GLOBAL)
else: self.lib = CDLL(join(modpath,"liblammps_%s" % name + lib_ext),
RTLD_GLOBAL)
except:
if not name: self.lib = CDLL("liblammps.so",RTLD_GLOBAL)
else: self.lib = CDLL("liblammps_%s.so" % name,RTLD_GLOBAL)
if not name: self.lib = CDLL("liblammps" + lib_ext,RTLD_GLOBAL)
else: self.lib = CDLL("liblammps_%s" % name + lib_ext,RTLD_GLOBAL)
# define ctypes API for each library method
# NOTE: should add one of these for each lib function