Commits

Jeremy Thurgood committed 3492369

Clean up a few things, fix python3 compat.

  • Participants
  • Parent commits eb2e8ac
  • Branches split-verify

Comments (0)

Files changed (2)

         # XXX: We use force_generic_engine here because vengine_cpy collects
         #      types when it writes the source.
         import os.path
-        from .verifier import Verifier, _caller_dir_pycache, _get_so_suffix
-        tmpdir = _caller_dir_pycache()
+        from .verifier import Verifier, _get_so_suffix
         self.ffi.verifier = Verifier(
-            self.ffi, source, tmpdir, libname, force_generic_engine=True,
-            **kwargs)
-        libfilename = libname + _get_so_suffix()
+            self.ffi, source, force_generic_engine=True, **kwargs)
+        libfilename = '_'.join([self._module_name, libname])
         self.ffi.verifier.make_library(
-            os.path.join(self._module_path, libfilename))
+            os.path.join(self._module_path, libfilename + _get_so_suffix()))
         self._module_source += '\n'.join([
             "def load_%s():",
             "    from cffi.verifier import Verifier",
             "    verifier._has_module = True",
             "    return verifier._load_library()",
             "",
-        ]) % (libname, libname)
+        ]) % (libname, libfilename)
 
     def write_ffi_module(self):
         import os

File testing/test_makelib.py

 from cffi import FFIBuilder
 
 
+def _clean_modules(tmpdir, module_name):
+    sys.path.remove(str(tmpdir))
+    for name in list(sys.modules.keys()):
+        if name and name.endswith(module_name):
+            sys.modules.pop(name)
+
+
 def test_ffibuilder_makelib(tmpdir):
     builder = FFIBuilder("foo_ffi", str(tmpdir))
     builder.cdef("""
     try:
         import foo_ffi
     finally:
-        sys.path.remove(str(tmpdir))
-        for name in sys.modules.keys():
-            if name.endswith('foo_ffi'):
-                sys.modules.pop(name)
+        _clean_modules(tmpdir, 'foo_ffi')
 
     lib = foo_ffi.load_foo()
     assert lib.sin(12.3) == math.sin(12.3)
     try:
         import foo_ffi
     finally:
-        sys.path.remove(str(tmpdir))
-        for name in sys.modules.keys():
-            if name.endswith('foo_ffi'):
-                sys.modules.pop(name)
+        _clean_modules(tmpdir, 'foo_ffi')
 
     lib = foo_ffi.load_foo()
     assert lib.sin(12.3) == math.sin(12.3)
     try:
         import foo_ffi
     finally:
-        sys.path.remove(str(tmpdir))
-        for name in sys.modules.keys():
-            if name.endswith('foo_ffi'):
-                sys.modules.pop(name)
+        _clean_modules(tmpdir, 'foo_ffi')
 
     lib_foo = foo_ffi.load_foo()
     assert lib_foo.sin(12.3) == math.sin(12.3)