Commit 5aefb2a8 authored by sjplimp's avatar sjplimp Committed by GitHub
Browse files

Merge pull request #219 from akohlmey/python-no-double-load

do not require the LAMMPS shared library when loading the python wrapper from inside LAMMPS
parents 40f2310a 0b426dad
Loading
Loading
Loading
Loading
+14 −7
Original line number Original line Diff line number Diff line
@@ -58,6 +58,13 @@ class lammps(object):
    # determine module location
    # determine module location


    modpath = dirname(abspath(getsourcefile(lambda:0)))
    modpath = dirname(abspath(getsourcefile(lambda:0)))
    self.lib = None

    # if a pointer to a LAMMPS object is handed in, all symbols should already be available.
    try:
      if ptr: self.lib = CDLL("",RTLD_GLOBAL)
    except:
      self.lib = None


    # load liblammps.so unless name is given.
    # load liblammps.so unless name is given.
    # e.g. if name = "g++", load liblammps_g++.so
    # e.g. if name = "g++", load liblammps_g++.so
@@ -66,7 +73,7 @@ class lammps(object):
    # does not need to be set for regular installations.
    # does not need to be set for regular installations.
    # fall back to loading with a relative path, which typically
    # fall back to loading with a relative path, which typically
    # requires LD_LIBRARY_PATH to be set appropriately.
    # requires LD_LIBRARY_PATH to be set appropriately.

    if not self.lib:
      try:
      try:
        if not name: self.lib = CDLL(join(modpath,"liblammps.so"),RTLD_GLOBAL)
        if not name: self.lib = CDLL(join(modpath,"liblammps.so"),RTLD_GLOBAL)
        else: self.lib = CDLL(join(modpath,"liblammps_%s.so" % name),RTLD_GLOBAL)
        else: self.lib = CDLL(join(modpath,"liblammps_%s.so" % name),RTLD_GLOBAL)