safer detection and load of lammps shared library

This commit is contained in:
Axel Kohlmeyer
2021-02-27 15:50:58 -05:00
parent 9efc83195a
commit 76ef7a9081

View File

@ -121,18 +121,16 @@ class lammps(object):
lib_ext = ".so" lib_ext = ".so"
if not self.lib: if not self.lib:
try: if name:
if not name: libpath = join(modpath,"liblammps_%s" % name + lib_ext)
self.lib = CDLL(join(modpath,"liblammps" + lib_ext),RTLD_GLOBAL)
else: else:
self.lib = CDLL(join(modpath,"liblammps_%s" % name + lib_ext), libpath = join(modpath,"liblammps" + lib_ext)
RTLD_GLOBAL) if not os.path.isfile(libpath):
except: if name:
if not name: libpath = "liblammps_%s" % name + lib_ext
self.lib = CDLL("liblammps" + lib_ext,RTLD_GLOBAL)
else: else:
self.lib = CDLL("liblammps_%s" % name + lib_ext,RTLD_GLOBAL) libpath = "liblammps" + lib_ext
self.lib = CDLL(libpath,RTLD_GLOBAL)
# declare all argument and return types for all library methods here. # declare all argument and return types for all library methods here.
# exceptions are where the arguments depend on certain conditions and # exceptions are where the arguments depend on certain conditions and