def __init__(self, libinfo, libnames, path=None):
self._dll = None
foundlibs = _findlib(libnames, path)
dllmsg = "PYSDL2_DLL_PATH: %s" % ("." or "unset")
if len(foundlibs) == 0:
raise RuntimeError("could not find any library for %s (%s)" %
(libinfo, dllmsg))
for libfile in foundlibs:
try:
self._dll = CDLL(libfile)
self._libfile = libfile
break
except Exception as exc:
# Could not load it, silently ignore that issue and move
# to the next one.
warnings.warn(repr(exc), ImportWarning)
if self._dll is None:
raise RuntimeError("found %s, but it's not usable for the library %s" %
(foundlibs, libinfo))
if path is not None and sys.platform in ("win32", "cli") and \
path in self._libfile:
os.environ["PATH"] = "%s;%s" % (path, os.environ["PATH"])
评论列表
文章目录