from ctypes import CDLL

def get_libpath():
    """
    Get the library path of the the distributed inform binary.
    """
    import os
    import re
    from os.path import dirname, abspath, realpath, join

    libre = re.compile(r"^inform-(\d+)\.(\d+)\.(\d+)$")

    root = dirname(abspath(realpath(__file__)))

    libdir = None
    major, minor, revision = 0, 0, 0
    for _, dirnames, _ in os.walk(root):
        for dirname in dirnames:
            match = libre.match(dirname) 
            if match:
                a, b, c = tuple(int(x) for x in match.group(1,2,3))
                if (major, minor, revision) < (a,b,c):
                    major, minor, revision = a, b, c
                    libdir = join(root, match.group())
                    break
        break

    if libdir is None:
        raise ImportError("cannot find libinform")
    else:
        return "{}/lib/libinform.so.{}.{}.{}".format(libdir,major,minor,revision)

_inform = CDLL(get_libpath())

from ctypes import CDLL

def get_libpath():
    """
    Get the library path of the the distributed inform binary.
    """
    import os
    import re
    from os.path import dirname, abspath, realpath, join
    from platform import system

    libre = re.compile(r"^inform-(\d+)\.(\d+)\.(\d+)$")

    root = dirname(abspath(realpath(__file__)))

    libdir = None
    major, minor, revision = 0, 0, 0
    for _, dirnames, _ in os.walk(root):
        for dirname in dirnames:
            match = libre.match(dirname) 
            if match:
                a, b, c = tuple(int(x) for x in match.group(1,2,3))
                if (major, minor, revision) < (a,b,c):
                    major, minor, revision = a, b, c
                    libdir = join(root, match.group())
                    break
        break

    if libdir is None:
        raise ImportError("cannot find libinform")

    if system() is 'Windows':
        return "{}/lib/inform.dll".format(libdir)
    else:
        return "{}/lib/libinform.so.{}.{}.{}".format(libdir,major,minor,revision)

_inform = CDLL(get_libpath())

Resolve the library on windows
Resolve the library on windows

  from ctypes import CDLL
  
  def get_libpath():
      """
      Get the library path of the the distributed inform binary.
      """
      import os
      import re
      from os.path import dirname, abspath, realpath, join
+     from platform import system
  
      libre = re.compile(r"^inform-(\d+)\.(\d+)\.(\d+)$")
  
      root = dirname(abspath(realpath(__file__)))
  
      libdir = None
      major, minor, revision = 0, 0, 0
      for _, dirnames, _ in os.walk(root):
          for dirname in dirnames:
              match = libre.match(dirname) 
              if match:
                  a, b, c = tuple(int(x) for x in match.group(1,2,3))
                  if (major, minor, revision) < (a,b,c):
                      major, minor, revision = a, b, c
                      libdir = join(root, match.group())
                      break
          break
  
      if libdir is None:
          raise ImportError("cannot find libinform")
+ 
+     if system() is 'Windows':
+         return "{}/lib/inform.dll".format(libdir)
      else:
          return "{}/lib/libinform.so.{}.{}.{}".format(libdir,major,minor,revision)
  
  _inform = CDLL(get_libpath())
  
Resolve the library on windows
## Code Before:
from ctypes import CDLL

def get_libpath():
    """
    Get the library path of the the distributed inform binary.
    """
    import os
    import re
    from os.path import dirname, abspath, realpath, join

    libre = re.compile(r"^inform-(\d+)\.(\d+)\.(\d+)$")

    root = dirname(abspath(realpath(__file__)))

    libdir = None
    major, minor, revision = 0, 0, 0
    for _, dirnames, _ in os.walk(root):
        for dirname in dirnames:
            match = libre.match(dirname) 
            if match:
                a, b, c = tuple(int(x) for x in match.group(1,2,3))
                if (major, minor, revision) < (a,b,c):
                    major, minor, revision = a, b, c
                    libdir = join(root, match.group())
                    break
        break

    if libdir is None:
        raise ImportError("cannot find libinform")
    else:
        return "{}/lib/libinform.so.{}.{}.{}".format(libdir,major,minor,revision)

_inform = CDLL(get_libpath())

## Instruction:
Resolve the library on windows
## Code After:
from ctypes import CDLL

def get_libpath():
    """
    Get the library path of the the distributed inform binary.
    """
    import os
    import re
    from os.path import dirname, abspath, realpath, join
    from platform import system

    libre = re.compile(r"^inform-(\d+)\.(\d+)\.(\d+)$")

    root = dirname(abspath(realpath(__file__)))

    libdir = None
    major, minor, revision = 0, 0, 0
    for _, dirnames, _ in os.walk(root):
        for dirname in dirnames:
            match = libre.match(dirname) 
            if match:
                a, b, c = tuple(int(x) for x in match.group(1,2,3))
                if (major, minor, revision) < (a,b,c):
                    major, minor, revision = a, b, c
                    libdir = join(root, match.group())
                    break
        break

    if libdir is None:
        raise ImportError("cannot find libinform")

    if system() is 'Windows':
        return "{}/lib/inform.dll".format(libdir)
    else:
        return "{}/lib/libinform.so.{}.{}.{}".format(libdir,major,minor,revision)

_inform = CDLL(get_libpath())
