From bb52dcb001aaa1ef55b178838d009b1b404cd36f Mon Sep 17 00:00:00 2001 From: Armin Rigo Date: Thu, 16 May 2024 23:06:37 +0200 Subject: [PATCH] add yet another flag to recompile() to avoid calling ffiplatform --- src/cffi/api.py | 6 ++++-- src/cffi/recompiler.py | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/cffi/api.py b/src/cffi/api.py index edeb7928..5a474f3d 100644 --- a/src/cffi/api.py +++ b/src/cffi/api.py @@ -693,7 +693,8 @@ def emit_c_code(self, filename): raise TypeError("emit_c_code() is only for C extension modules, " "not for dlopen()-style pure Python modules") recompile(self, module_name, source, - c_file=filename, call_c_compiler=False, **kwds) + c_file=filename, call_c_compiler=False, + uses_ffiplatform=False, **kwds) def emit_python_code(self, filename): from .recompiler import recompile @@ -705,7 +706,8 @@ def emit_python_code(self, filename): raise TypeError("emit_python_code() is only for dlopen()-style " "pure Python modules, not for C extension modules") recompile(self, module_name, source, - c_file=filename, call_c_compiler=False, **kwds) + c_file=filename, call_c_compiler=False, + uses_ffiplatform=False, **kwds) def compile(self, tmpdir='.', verbose=0, target=None, debug=None): """The 'target' argument gives the final file name of the diff --git a/src/cffi/recompiler.py b/src/cffi/recompiler.py index 4167bc05..450e978d 100644 --- a/src/cffi/recompiler.py +++ b/src/cffi/recompiler.py @@ -1519,7 +1519,8 @@ def _patch_for_target(patchlist, target): def recompile(ffi, module_name, preamble, tmpdir='.', call_c_compiler=True, c_file=None, source_extension='.c', extradir=None, - compiler_verbose=1, target=None, debug=None, **kwds): + compiler_verbose=1, target=None, debug=None, + uses_ffiplatform=True, **kwds): if not isinstance(module_name, str): module_name = module_name.encode('ascii') if ffi._windows_unicode: @@ -1543,7 +1544,10 @@ def recompile(ffi, module_name, preamble, tmpdir='.', call_c_compiler=True, else: target = '*' # - ext = ffiplatform.get_extension(ext_c_file, module_name, **kwds) + if uses_ffiplatform: + ext = ffiplatform.get_extension(ext_c_file, module_name, **kwds) + else: + ext = None updated = make_c_source(ffi, module_name, preamble, c_file, verbose=compiler_verbose) if call_c_compiler: