Commits

aholkner  committed 272f9a9

Better error message for missing SDL lib

  • Participants
  • Parent commits f135a2b
  • Branches ctypes-soc

Comments (0)

Files changed (2)

  - transform.rotate on big endian fixed
  - Workaround for TTF_RenderText_Solid not working on OS X
 
+SDL-ctypes 0.08
+---------------
+ - Meaningful exception raised when library not loaded
+
 Pygame-ctypes 0.07
 ------------------
  - SDL_INIT_NOPARACHUTE init flag passed
 def _version_string(v):
     return '%d.%d.%d' % _version_parts(v)
 
+def _platform_library_name(library):
+    if sys.platform[:5] == 'linux':
+        return 'lib%s.so' % library
+    elif sys.platform == 'darwin':
+        return '%s.framework' % library
+    elif sys.platform == 'windows':
+        return '%s.dll' % library
+    return library
+
 class SDL_DLL:
     def __init__(self, library_name, version_function_name):
         self.library_name = library_name
-        self._dll = getattr(cdll, find_library(library_name))
+        library = find_library(library_name)
+        if not library:
+            raise ImportError, 'Dynamic library "%s" was not found' % \
+                _platform_library_name(library_name)
+        self._dll = getattr(cdll, library)
         '''
         if sys.platform == 'darwin':
             import ctypes.macholib.dyld