Author: Armin Rigo <ar...@tunes.org>
Branch: cffi-static-callback-embedding
Changeset: r81809:4def39652ed6
Date: 2016-01-15 16:35 +0000
http://bitbucket.org/pypy/pypy/changeset/4def39652ed6/

Log:    fix fix fix

diff --git a/lib-python/2.7/distutils/command/build_ext.py 
b/lib-python/2.7/distutils/command/build_ext.py
--- a/lib-python/2.7/distutils/command/build_ext.py
+++ b/lib-python/2.7/distutils/command/build_ext.py
@@ -685,13 +685,17 @@
         # the previous version of this code did.  This should work for
         # CPython too.  The point is that on PyPy with cpyext, the
         # config var 'SO' is just ".so" but we want to return
-        # ".pypy-VERSION.so" instead.
-        so_ext = _get_c_extension_suffix()
+        # ".pypy-VERSION.so" instead.  Note a further tweak for cffi's
+        # embedding mode: if EXT_SUFFIX is also defined, use that
+        # directly.
+        so_ext = get_config_var('EXT_SUFFIX')
         if so_ext is None:
-            so_ext = get_config_var('SO')     # fall-back
-        # extensions in debug_mode are named 'module_d.pyd' under windows
-        if os.name == 'nt' and self.debug:
-            so_ext = '_d.pyd'
+            so_ext = _get_c_extension_suffix()
+            if so_ext is None:
+                so_ext = get_config_var('SO')     # fall-back
+            # extensions in debug_mode are named 'module_d.pyd' under windows
+            if os.name == 'nt' and self.debug:
+                so_ext = '_d.pyd'
         return os.path.join(*ext_path) + so_ext
 
     def get_export_symbols (self, ext):
diff --git a/lib_pypy/cffi/api.py b/lib_pypy/cffi/api.py
--- a/lib_pypy/cffi/api.py
+++ b/lib_pypy/cffi/api.py
@@ -545,6 +545,12 @@
     def _apply_embedding_fix(self, kwds):
         # must include an argument like "-lpython2.7" for the compiler
         if '__pypy__' in sys.builtin_module_names:
+            if hasattr(sys, 'prefix'):
+                import os
+                libdir = os.path.join(sys.prefix, 'bin')
+                dirs = kwds.setdefault('library_dirs', [])
+                if libdir not in dirs:
+                    dirs.append(libdir)
             pythonlib = "pypy-c"
         else:
             if sys.platform == "win32":
@@ -557,9 +563,9 @@
                     (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
             if hasattr(sys, 'abiflags'):
                 pythonlib += sys.abiflags
-        libraries = kwds.get('libraries', [])
+        libraries = kwds.setdefault('libraries', [])
         if pythonlib not in libraries:
-            kwds['libraries'] = libraries + [pythonlib]
+            libraries.append(pythonlib)
 
     def set_source(self, module_name, source, source_extension='.c', **kwds):
         if hasattr(self, '_assigned_source'):
diff --git a/pypy/module/test_lib_pypy/cffi_tests/embedding/test_basic.py 
b/pypy/module/test_lib_pypy/cffi_tests/embedding/test_basic.py
--- a/pypy/module/test_lib_pypy/cffi_tests/embedding/test_basic.py
+++ b/pypy/module/test_lib_pypy/cffi_tests/embedding/test_basic.py
@@ -21,7 +21,7 @@
         ffi._apply_embedding_fix(kwds)
         ffi.set_source("_test_lib_python_found", "", **kwds)
         try:
-            ffi.compile(tmpdir=tmpdir)
+            ffi.compile(tmpdir=tmpdir, verbose=True)
         except cffi.VerificationError as e:
             _link_error = e
         else:
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to