Author: Ronan Lamy <ronan.l...@gmail.com>
Branch: testing-cleanup
Changeset: r85205:cc4219028500
Date: 2016-06-17 03:46 +0100
http://bitbucket.org/pypy/pypy/changeset/cc4219028500/

Log:    Don't use ECI

diff --git a/pypy/module/cpyext/test/support.py 
b/pypy/module/cpyext/test/support.py
--- a/pypy/module/cpyext/test/support.py
+++ b/pypy/module/cpyext/test/support.py
@@ -10,31 +10,30 @@
 else:
     so_ext = 'dll'
 
-def c_compile(cfilenames, eci, outputfilename):
+def c_compile(cfilenames, outputfilename,
+        compile_extra=None, link_extra=None,
+        include_dirs=None, libraries=None, library_dirs=None):
+    compile_extra = compile_extra or []
+    link_extra = link_extra or []
+    include_dirs = include_dirs or []
+    libraries = libraries or []
+    library_dirs = library_dirs or []
     self = rpy_platform
-    libraries = list(eci.libraries)
-    include_dirs = list(eci.include_dirs)
-    library_dirs = list(eci.library_dirs)
-    compile_extra = list(eci.compile_extra)
-    link_extra = list(eci.link_extra)
-    frameworks = list(eci.frameworks)
     if not self.name in ('win32', 'darwin', 'cygwin'): # xxx
         if 'm' not in libraries:
             libraries.append('m')
         if 'pthread' not in libraries:
             libraries.append('pthread')
     if self.name == 'win32':
-        link_extra += ['/DEBUG'] # generate .pdb file
+        link_extra = link_extra + ['/DEBUG'] # generate .pdb file
     if self.name == 'darwin':
         # support Fink & Darwinports
         for s in ('/sw/', '/opt/local/'):
-            if s + 'include' not in include_dirs and \
-                os.path.exists(s + 'include'):
+            if (s + 'include' not in include_dirs
+                    and os.path.exists(s + 'include')):
                 include_dirs.append(s + 'include')
             if s + 'lib' not in library_dirs and os.path.exists(s + 'lib'):
                 library_dirs.append(s + 'lib')
-        for framework in frameworks:
-            link_extra += ['-framework', framework]
 
     outputfilename = py.path.local(outputfilename).new(ext=so_ext)
     saved_environ = os.environ.copy()
diff --git a/pypy/module/cpyext/test/test_cpyext.py 
b/pypy/module/cpyext/test/test_cpyext.py
--- a/pypy/module/cpyext/test/test_cpyext.py
+++ b/pypy/module/cpyext/test/test_cpyext.py
@@ -7,7 +7,6 @@
 from pypy import pypydir
 from pypy.interpreter import gateway
 from rpython.rtyper.lltypesystem import lltype, ll2ctypes
-from rpython.translator.tool.cbuild import ExternalCompilationInfo
 from rpython.translator.gensupp import uniquemodulename
 from rpython.tool.udir import udir
 from pypy.module.cpyext import api
@@ -41,17 +40,17 @@
         files.append(filename)
     return files
 
-def create_so(modname, include_dirs,
-        source_strings=None,
-        source_files=None,
-        **kwds):
+def create_so(modname, include_dirs, source_strings=None, source_files=None,
+        compile_extra=None, link_extra=None, libraries=None):
     dirname = (udir/uniquemodulename('module')).ensure(dir=1)
     if source_strings:
         assert not source_files
         files = convert_sources_to_files(source_strings, dirname)
         source_files = files
-    eci = ExternalCompilationInfo(include_dirs=include_dirs, **kwds)
-    soname = c_compile(source_files, eci, outputfilename=str(dirname/modname))
+    soname = c_compile(source_files, outputfilename=str(dirname/modname),
+        compile_extra=compile_extra, link_extra=link_extra,
+        include_dirs=include_dirs,
+        libraries=libraries)
     return soname
 
 def compile_extension_module(space, modname, include_dirs=[],
@@ -66,31 +65,32 @@
     Any extra keyword arguments are passed on to ExternalCompilationInfo to
     build the module (so specify your source with one of those).
     """
-    kwds = {}
     state = space.fromcache(State)
     api_library = state.api_lib
     if sys.platform == 'win32':
-        kwds["libraries"] = [api_library]
+        libraries = [api_library]
         # '%s' undefined; assuming extern returning int
-        kwds["compile_extra"] = ["/we4013"]
+        compile_extra = ["/we4013"]
         # prevent linking with PythonXX.lib
         w_maj, w_min = space.fixedview(space.sys.get('version_info'), 5)[:2]
-        kwds["link_extra"] = ["/NODEFAULTLIB:Python%d%d.lib" %
+        link_extra = ["/NODEFAULTLIB:Python%d%d.lib" %
                               (space.int_w(w_maj), space.int_w(w_min))]
-    elif sys.platform == 'darwin':
-        kwds["link_files"] = [str(api_library + '.dylib')]
     else:
-        kwds["link_files"] = [str(api_library + '.so')]
+        libraries = []
         if sys.platform.startswith('linux'):
-            kwds["compile_extra"] = ["-Werror", "-g", "-O0", "-fPIC"]
-            kwds["link_extra"] = ["-g"]
+            compile_extra = ["-Werror", "-g", "-O0", "-fPIC"]
+            link_extra = ["-g"]
+        else:
+            compile_extra = link_extra = None
 
     modname = modname.split('.')[-1]
     soname = create_so(modname,
             include_dirs=api.include_dirs + include_dirs,
             source_files=source_files,
             source_strings=source_strings,
-            **kwds)
+            compile_extra=compile_extra,
+            link_extra=link_extra,
+            libraries=libraries)
     from pypy.module.imp.importing import get_so_extension
     pydname = soname.new(purebasename=modname, ext=get_so_extension(space))
     soname.rename(pydname)
@@ -108,22 +108,24 @@
     Any extra keyword arguments are passed on to ExternalCompilationInfo to
     build the module (so specify your source with one of those).
     """
-    kwds = {}
     if sys.platform == 'win32':
-        kwds["compile_extra"] = ["/we4013"]
-        kwds["link_extra"] = ["/LIBPATH:" + os.path.join(sys.exec_prefix, 
'libs')]
+        compile_extra = ["/we4013"]
+        link_extra = ["/LIBPATH:" + os.path.join(sys.exec_prefix, 'libs')]
     elif sys.platform == 'darwin':
+        compile_extra = link_extra = None
         pass
     elif sys.platform.startswith('linux'):
-        kwds["compile_extra"] = [
+        compile_extra = [
             "-O0", "-g", "-Werror=implicit-function-declaration", "-fPIC"]
+        link_extra = None
 
     modname = modname.split('.')[-1]
     soname = create_so(modname,
             include_dirs=[space.include_dir] + include_dirs,
             source_files=source_files,
             source_strings=source_strings,
-            **kwds)
+            compile_extra=compile_extra,
+            link_extra=link_extra)
     return str(soname)
 
 def freeze_refcnts(self):
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to