[pypy-commit] cffi split-verify: Collect built filepaths.
jerith
noreply at buildbot.pypy.org
Sun Oct 6 13:13:52 CEST 2013
Author: Jeremy Thurgood <firxen at gmail.com>
Branch: split-verify
Changeset: r1353:e179cc8d6f7a
Date: 2013-10-06 13:13 +0200
http://bitbucket.org/cffi/cffi/changeset/e179cc8d6f7a/
Log: Collect built filepaths.
diff --git a/cffi/api.py b/cffi/api.py
--- a/cffi/api.py
+++ b/cffi/api.py
@@ -455,6 +455,7 @@
self._module_name = module_name
self._module_path = module_path
self.ffi = FFI(backend=backend)
+ self._built_files = []
self._module_source = "\n".join([
"from cffi import FFI",
"",
@@ -484,8 +485,9 @@
self.ffi.verifier = Verifier(
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 + _get_so_suffix()))
+ libfilepath = os.path.join(
+ self._module_path, libfilename + _get_so_suffix())
+ self.ffi.verifier.make_library(libfilepath)
self._module_source += '\n'.join([
"def load_%s():",
" from cffi.verifier import Verifier",
@@ -497,6 +499,7 @@
" return verifier._load_library()",
"",
]) % (libname, libfilename)
+ self._built_files.append(libfilepath)
def write_ffi_module(self):
import os
@@ -505,9 +508,14 @@
except OSError:
pass
- module_filename = self._module_name + '.py'
- file = open(os.path.join(self._module_path, module_filename), 'w')
+ module_filepath = os.path.join(
+ self._module_path, self._module_name + '.py')
+ file = open(module_filepath, 'w')
try:
file.write(self._module_source)
finally:
file.close()
+ self._built_files.append(module_filepath)
+
+ def list_built_files(self):
+ return self._built_files
diff --git a/testing/test_makelib.py b/testing/test_makelib.py
--- a/testing/test_makelib.py
+++ b/testing/test_makelib.py
@@ -1,6 +1,7 @@
import math
import sys
from cffi import FFIBuilder
+from cffi.verifier import _get_so_suffix
def _clean_modules(tmpdir, module_name):
@@ -18,6 +19,11 @@
builder.makelib('foo', '#include <math.h>')
builder.write_ffi_module()
+ assert builder.list_built_files() == [
+ str(tmpdir.join('foo_ffi_foo' + _get_so_suffix())),
+ str(tmpdir.join('foo_ffi.py')),
+ ]
+
sys.path.append(str(tmpdir))
try:
import foo_ffi
@@ -36,6 +42,10 @@
builder.add_dlopen('foo', "m")
builder.write_ffi_module()
+ assert builder.list_built_files() == [
+ str(tmpdir.join('foo_ffi.py')),
+ ]
+
sys.path.append(str(tmpdir))
try:
import foo_ffi
@@ -55,6 +65,11 @@
builder.add_dlopen('bar', "m")
builder.write_ffi_module()
+ assert builder.list_built_files() == [
+ str(tmpdir.join('foo_ffi_foo' + _get_so_suffix())),
+ str(tmpdir.join('foo_ffi.py')),
+ ]
+
sys.path.append(str(tmpdir))
try:
import foo_ffi
More information about the pypy-commit
mailing list