Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > bdd62600b4f13fb2a9b37c1e962ce48f > files > 2

python-webm-0.2.2-4.fc18.src.rpm

diff -ur python-webm.orig/webm/__init__.py python-webm/webm/__init__.py
--- python-webm.orig/webm/__init__.py   2012-03-06 16:11:05.000000000 -0700
+++ python-webm/webm/__init__.py    2013-10-08 10:27:28.404099373 -0700
@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 """
 Copyright (c) 2011, Daniele Esposti <expo@expobrain.net>
+Copyright (c) 2012, 2013 Antoine Martin <antoine@devloop.org.uk>
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -25,7 +26,7 @@
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 """
 
-import sys
+import sys, os
 from ctypes import cdll as loader
 
 
@@ -38,17 +39,25 @@
 
 # Per-OS setup
 if sys.platform == "win32":
-    _LIBRARY = "libwebp_a.dll"
-
-elif sys.platform == "linux2":
-    _LIBRARY = "libwebp.so.0"
+    _LIBRARY_NAMES = ["libwebp.dll"]
 
 elif sys.platform == "darwin":
-    _LIBRARY = "libwebp.dylib"
+    _LIBRARY_NAMES = ["libwebp.dylib"]
+
+elif os.name == "posix":
+    _LIBRARY_NAMES = ["libwebp.so.4", "libwebp.so.2"]
 
 else:
-    raise NotImplementedError(
-        "Test non implemented under {0}".format(sys.platform))
+    raise ImportError(
+        "Test non implemented under %s / %s" % (os.name, sys.platform))
 
 # Load library
-_LIBRARY = loader.LoadLibrary(_LIBRARY)
+_LIBRARY = None
+for name in _LIBRARY_NAMES:
+    try:
+        _LIBRARY = loader.LoadLibrary(name)
+        break
+    except:
+        pass
+if _LIBRARY is None:
+    raise ImportError("Could not find webp library from %s" % str(_LIBRARY_NAMES))