Skip to content

Commit

Permalink
add yet another flag to recompile() to avoid calling ffiplatform (#81)
Browse files Browse the repository at this point in the history
Co-authored-by: Armin Rigo <armin.rigo@gmail.com>
(cherry picked from commit 00cb9fc)
  • Loading branch information
nitzmahone committed Sep 4, 2024
1 parent 1c292c1 commit 61deb5f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/cffi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/cffi/recompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,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:
Expand All @@ -1556,7 +1557,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:
Expand Down

0 comments on commit 61deb5f

Please sign in to comment.