[pypy-svn] r66184 - in pypy/trunk/pypy: rpython/lltypesystem rpython/lltypesystem/test translator/platform translator/platform/test

arigo at codespeak.net arigo at codespeak.net
Sun Jul 12 13:53:37 CEST 2009


Author: arigo
Date: Sun Jul 12 13:53:35 2009
New Revision: 66184

Modified:
   pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py
   pypy/trunk/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
   pypy/trunk/pypy/translator/platform/__init__.py
   pypy/trunk/pypy/translator/platform/darwin.py
   pypy/trunk/pypy/translator/platform/linux.py
   pypy/trunk/pypy/translator/platform/test/test_distutils.py
   pypy/trunk/pypy/translator/platform/test/test_maemo.py
   pypy/trunk/pypy/translator/platform/test/test_platform.py
   pypy/trunk/pypy/translator/platform/windows.py
Log:
Bulk-revert all changes from r66152 onwards.
Fijal did not do anything since we discussed the
issue two days ago on irc, so better have a
working base from which to re-check-in correct
changes than leaving the current broken files.


Modified: pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py	(original)
+++ pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py	Sun Jul 12 13:53:35 2009
@@ -19,7 +19,6 @@
 from pypy.rpython.lltypesystem.rclass import OBJECT
 from pypy.rpython.annlowlevel import base_ptr_lltype
 from pypy.rpython import raddress
-from pypy.translator.platform import platform
 
 def uaddressof(obj):
     return fixid(ctypes.addressof(obj))
@@ -814,23 +813,10 @@
             cfunc = get_on_lib(ctypes.windll.kernel32, funcname)
     else:
         cfunc = None
-        not_found = []
         for libname in libraries:
-            libpath = None
-            ext = platform.so_ext
-            prefixes = platform.so_prefixes
-            for dir in eci.library_dirs:
-                if libpath:
-                    break
-                for prefix in prefixes:
-                    tryfile = os.path.join(dir, prefix + libname + '.' + ext)
-                    if os.path.isfile(tryfile):
-                        libpath = tryfile
-                        break
-            if not libpath:
-                libpath = ctypes.util.find_library(libname)
-                if not libpath and os.path.isabs(libname):
-                    libpath = libname
+            libpath = ctypes.util.find_library(libname)
+            if not libpath and os.path.isabs(libname):
+                libpath = libname
             if libpath:
                 dllclass = getattr(ctypes, calling_conv + 'dll')
                 # urgh, cannot pass the flag to dllclass.LoadLibrary
@@ -838,20 +824,11 @@
                 cfunc = get_on_lib(clib, funcname)
                 if cfunc is not None:
                     break
-            else:
-                not_found.append(libname)
 
     if cfunc is None:
         # function name not found in any of the libraries
         if not libraries:
             place = 'the standard C library (missing libraries=...?)'
-        elif len(not_found) == len(libraries):
-            if len(not_found) == 1:
-                raise NotImplementedError(
-                    'cannot find the library %r' % (not_found[0],))
-            else:
-                raise NotImplementedError(
-                    'cannot find any of the libraries %r' % (not_found,))
         elif len(libraries) == 1:
             place = 'library %r' % (libraries[0],)
         else:

Modified: pypy/trunk/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/test/test_ll2ctypes.py	(original)
+++ pypy/trunk/pypy/rpython/lltypesystem/test/test_ll2ctypes.py	Sun Jul 12 13:53:35 2009
@@ -15,7 +15,6 @@
 from pypy.rpython.test.test_llinterp import interpret
 from pypy.annotation.annrpython import RPythonAnnotator
 from pypy.rpython.rtyper import RPythonTyper
-from pypy.tool.udir import udir
 
 class TestLL2Ctypes(object):
 
@@ -995,46 +994,3 @@
         v2 = ctypes2lltype(llmemory.GCREF, ctypes.c_void_p(1235))
         assert v2 != v
         
-class TestPlatform(object):
-    def test_lib_on_libpaths(self):
-        from pypy.translator.platform import platform
-        from pypy.translator.tool.cbuild import ExternalCompilationInfo
-
-        tmpdir = udir.join('lib_on_libppaths')
-        tmpdir.ensure(dir=1)
-        c_file = tmpdir.join('c_file.c')
-        c_file.write('int f(int a, int b) { return (a + b); }')
-        eci = ExternalCompilationInfo(export_symbols=['f'])
-        so = platform.compile([c_file], eci, standalone=False)
-        eci = ExternalCompilationInfo(
-            libraries = ['c_file'],
-            library_dirs = [str(so.dirpath())]
-        )
-        f = rffi.llexternal('f', [rffi.INT, rffi.INT], rffi.INT,
-                            compilation_info=eci)
-        assert f(3, 4) == 7
-
-    def test_prefix(self):
-
-        if sys.platform != 'linux2':
-            py.test.skip("Not supported")
-
-        from pypy.translator.platform import platform
-        from pypy.translator.tool.cbuild import ExternalCompilationInfo
-
-        tmpdir = udir.join('lib_on_libppaths_prefix')
-        tmpdir.ensure(dir=1)
-        c_file = tmpdir.join('c_file.c')
-        c_file.write('int f(int a, int b) { return (a + b); }')
-        eci = ExternalCompilationInfo()
-        so = platform.compile([c_file], eci, standalone=False)
-        sopath = py.path.local(so)
-        sopath.move(sopath.dirpath().join('libc_file.so'))
-        eci = ExternalCompilationInfo(
-            libraries = ['c_file'],
-            library_dirs = [str(so.dirpath())]
-        )
-        f = rffi.llexternal('f', [rffi.INT, rffi.INT], rffi.INT,
-                            compilation_info=eci)
-        assert f(3, 4) == 7
-        

Modified: pypy/trunk/pypy/translator/platform/__init__.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/__init__.py	(original)
+++ pypy/trunk/pypy/translator/platform/__init__.py	Sun Jul 12 13:53:35 2009
@@ -52,8 +52,6 @@
     name = "abstract platform"
     c_environ = None
 
-    so_prefixes = ['']
-
     def __init__(self, cc):
         if self.__class__ is Platform:
             raise TypeError("You should not instantiate Platform class directly")
@@ -72,12 +70,7 @@
             ofiles.append(self._compile_c_file(self.cc, cfile, compile_args))
         return ofiles
 
-    def execute(self, executable, args=None, env=None, compilation_info=None):
-        if env is None:
-            env = {}
-        if compilation_info is not None:
-            env['LD_LIBRARY_PATH'] = ':'.join(
-                [str(i) for i in compilation_info.library_dirs])
+    def execute(self, executable, args=None, env=None):
         returncode, stdout, stderr = _run_subprocess(str(executable), args,
                                                      env)
         return ExecutionResult(returncode, stdout, stderr)
@@ -127,13 +120,9 @@
         cflags = self.cflags + extra
         return (cflags + list(eci.compile_extra) + args)
 
-    def _link_args_from_eci(self, eci, standalone):
-        if standalone:
-            library_dirs = self._libdirs(eci.library_dirs)
-            libraries = self._libs(eci.libraries)
-        else:
-            library_dirs = []
-            libraries = []
+    def _link_args_from_eci(self, eci):
+        library_dirs = self._libdirs(eci.library_dirs)
+        libraries = self._libs(eci.libraries)
         link_files = self._linkfiles(eci.link_files)
         return (library_dirs + libraries + self.link_flags +
                 link_files + list(eci.link_extra))
@@ -148,8 +137,8 @@
                 exe_name += '.' + self.exe_ext
         else:
             exe_name += '.' + self.so_ext
-        largs = self._link_args_from_eci(eci, standalone)
-        return self._link(self.cc, ofiles, largs, standalone, exe_name)
+        return self._link(self.cc, ofiles, self._link_args_from_eci(eci),
+                          standalone, exe_name)
 
     # below are some detailed informations for platforms
 

Modified: pypy/trunk/pypy/translator/platform/darwin.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/darwin.py	(original)
+++ pypy/trunk/pypy/translator/platform/darwin.py	Sun Jul 12 13:53:35 2009
@@ -38,8 +38,8 @@
             args.append(f)
         return args
 
-    def _link_args_from_eci(self, eci, standalone):
-        args = super(Darwin, self)._link_args_from_eci(eci, standalone)
+    def _link_args_from_eci(self, eci):
+        args = super(Darwin, self)._link_args_from_eci(eci)
         frameworks = self._frameworks(eci.frameworks)
         include_dirs = self._includedirs(eci.include_dirs)
         return (args + frameworks + include_dirs)

Modified: pypy/trunk/pypy/translator/platform/linux.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/linux.py	(original)
+++ pypy/trunk/pypy/translator/platform/linux.py	Sun Jul 12 13:53:35 2009
@@ -13,7 +13,6 @@
     standalone_only = []
     shared_only = []
     so_ext = 'so'
-    so_prefixes = ['lib', '']
     
     def _args_for_shared(self, args):
         return ['-shared'] + args

Modified: pypy/trunk/pypy/translator/platform/test/test_distutils.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/test/test_distutils.py	(original)
+++ pypy/trunk/pypy/translator/platform/test/test_distutils.py	Sun Jul 12 13:53:35 2009
@@ -8,6 +8,3 @@
 
     def test_nice_errors(self):
         py.test.skip("Unsupported")
-
-    def test_shared_no_links(self):
-        py.test.skip("Unsupported")

Modified: pypy/trunk/pypy/translator/platform/test/test_maemo.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/test/test_maemo.py	(original)
+++ pypy/trunk/pypy/translator/platform/test/test_maemo.py	Sun Jul 12 13:53:35 2009
@@ -31,6 +31,3 @@
         executable = self.platform.compile([cfile], eci)
         res = self.platform.execute(executable)
         self.check_res(res)
-
-    def test_shared_no_links(self):
-        py.test.skip("Unsupported")

Modified: pypy/trunk/pypy/translator/platform/test/test_platform.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/test/test_platform.py	(original)
+++ pypy/trunk/pypy/translator/platform/test/test_platform.py	Sun Jul 12 13:53:35 2009
@@ -1,5 +1,5 @@
 
-import py, sys, ctypes
+import py, sys
 from pypy.tool.udir import udir
 from pypy.translator.platform import CompilationError, Platform
 from pypy.translator.platform import host
@@ -102,18 +102,6 @@
         res = self.platform.execute(executable)
         assert res.out.startswith('4.0')
 
-    def test_shared_no_links(self):
-        eci = ExternalCompilationInfo(libraries = ['xxxxxxxxxxxxxxxxxxx'])
-        tmpdir = udir.join('shared_no_links').ensure(dir=1)
-        c_file = tmpdir.join('shared1.c')
-        c_file.write('''
-        int f(int a, int b)
-        {
-            return (a + b);
-        }
-        ''')
-        library = self.platform.compile([c_file], eci, standalone=False)
-        assert ctypes.CDLL(str(library)).f(3, 4) == 7
 
 def test_equality():
     class X(Platform):

Modified: pypy/trunk/pypy/translator/platform/windows.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/windows.py	(original)
+++ pypy/trunk/pypy/translator/platform/windows.py	Sun Jul 12 13:53:35 2009
@@ -133,9 +133,8 @@
     def _args_for_shared(self, args):
         return ['/dll'] + args
 
-    def _link_args_from_eci(self, eci, standalone):
-        # Windows needs to resolve all symbols even for DLLs
-        args = super(MsvcPlatform, self)._link_args_from_eci(eci, standalone=True)
+    def _link_args_from_eci(self, eci):
+        args = super(MsvcPlatform, self)._link_args_from_eci(eci)
         return args + ['/EXPORT:%s' % symbol for symbol in eci.export_symbols]
 
     def _compile_c_file(self, cc, cfile, compile_args):



More information about the Pypy-commit mailing list