[Numpy-svn] r5369 - in branches/1.1.x/numpy: . tests

numpy-svn@scip... numpy-svn@scip...
Wed Jul 9 01:25:50 CDT 2008


Author: cdavid
Date: 2008-07-09 01:25:42 -0500 (Wed, 09 Jul 2008)
New Revision: 5369

Modified:
   branches/1.1.x/numpy/ctypeslib.py
   branches/1.1.x/numpy/tests/test_ctypeslib.py
Log:
Merge revision 5236 to fix ctypes load_library.

Modified: branches/1.1.x/numpy/ctypeslib.py
===================================================================
--- branches/1.1.x/numpy/ctypeslib.py	2008-07-09 06:05:18 UTC (rev 5368)
+++ branches/1.1.x/numpy/ctypeslib.py	2008-07-09 06:25:42 UTC (rev 5369)
@@ -29,7 +29,10 @@
             import warnings
             warnings.warn("All features of ctypes interface may not work " \
                           "with ctypes < 1.0.1")
-        if '.' not in libname:
+
+        ext = os.path.splitext(libname)[1]
+
+        if not ext:
             # Try to load library with platform-specific name, otherwise
             # default to libname.[so|pyd].  Sometimes, these files are built
             # erroneously on non-linux platforms.
@@ -38,6 +41,8 @@
                 libname_ext.insert(0, '%s.dll' % libname)
             elif sys.platform == 'darwin':
                 libname_ext.insert(0, '%s.dylib' % libname)
+        else:
+            libname_ext = [libname]
 
         loader_path = os.path.abspath(loader_path)
         if not os.path.isdir(loader_path):

Modified: branches/1.1.x/numpy/tests/test_ctypeslib.py
===================================================================
--- branches/1.1.x/numpy/tests/test_ctypeslib.py	2008-07-09 06:05:18 UTC (rev 5368)
+++ branches/1.1.x/numpy/tests/test_ctypeslib.py	2008-07-09 06:25:42 UTC (rev 5369)
@@ -12,6 +12,22 @@
                   " (import error was: %s)" % str(e)
             print msg
 
+    def check_basic2(self):
+        """Regression for #801: load_library with a full library name
+        (including extension) does not work."""
+        try:
+            try:
+                from distutils import sysconfig
+                so = sysconfig.get_config_var('SO')
+                cdll = load_library('multiarray%s' % so,
+                                    np.core.multiarray.__file__)
+            except ImportError:
+                print "No distutils available, skipping test."
+        except ImportError, e:
+            msg = "ctypes is not available on this python: skipping the test" \
+                  " (import error was: %s)" % str(e)
+            print msg
+
 class TestNdpointer(NumpyTestCase):
     def check_dtype(self):
         dt = np.intc



More information about the Numpy-svn mailing list