def __init__(self, libinfo, libnames, path=None):
self._dll = None
foundlibs = _findlib(libnames, path)
dllmsg = "PYSDL2_DLL_PATH: %s" % (os.getenv("PYSDL2_DLL_PATH") 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 the DLL, move to the next, but inform the user
# about something weird going on - this may become noisy, but
# is better than confusing the users with the RuntimeError below
warnings.warn(repr(exc), DLLWarning)
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",) and \
path in self._libfile:
os.environ["PATH"] = "%s;%s" % (path, os.environ["PATH"])
评论列表
文章目录