def _load_library(dllname, loadfunction, dllpaths=('', )):
        """Load a DLL via ctypes load function. Return None on failure.

        By default, try to load the DLL from the current package
        directory first, then from the Windows DLL search path.

        """
        try:
            dllpaths = (os.path.abspath(
                os.path.dirname(__file__)), ) + dllpaths
        except NameError:
            pass  # PyPy and frozen distributions have no __file__ attribute
        for path in dllpaths:
            if path:
                # Temporarily add the path to the PATH environment variable
                # so Windows can find additional DLL dependencies.
                try:
                    oldenv = os.environ['PATH']
                    os.environ['PATH'] = path + ';' + oldenv
                except __HOLE__:
                    oldenv = None
            try:
                return loadfunction(os.path.join(path, dllname))
            except WindowsError:
                pass
            finally:
                if path and oldenv is not None:
                    os.environ['PATH'] = oldenv
        return None

    # In order to improve diagnosis of a common Windows dependency
    # issue, we explicitly test that we can load the HDF5 dll before
    # loading tables.utilsextensions.
dataset/ETHPy150Open PyTables/PyTables/tables/__init__.py/_load_library