diff options
author | Max Bélanger <aeromax@gmail.com> | 2020-10-02 08:45:02 +0000 |
---|---|---|
committer | Max Bélanger <aeromax@gmail.com> | 2020-10-02 08:45:02 +0000 |
commit | ef64e896958e20f577003341fab4fbd14f4cfb18 (patch) | |
tree | a429105d4c0f83b2db24b4c1b18ad828000bdff6 /setup.py | |
parent | 6684ff8f9112b8dd7166b34ea0f916695fe7a26c (diff) | |
download | cffi-ef64e896958e20f577003341fab4fbd14f4cfb18.tar.gz |
Fix building `cffi` for macOS with Apple Silicon support + backwards compatibility
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 31 |
1 files changed, 5 insertions, 26 deletions
@@ -149,39 +149,18 @@ if COMPILE_LIBFFI: sources.extend(os.path.join(COMPILE_LIBFFI, filename) for filename in _filenames) else: - if 'darwin' in sys.platform and macosx_deployment_target() >= (10, 15): - # use libffi from Mac OS SDK if we're targetting 10.15 (including - # on arm64). This libffi is safe against the crash-after-fork - # issue described in _cffi_backend.c. Also, arm64 uses a different - # ABI for calls to vararg functions as opposed to regular functions. - extra_compile_args += ['-iwithsysroot/usr/include/ffi'] - define_macros += [('CFFI_TRUST_LIBFFI', '1'), - ('HAVE_FFI_PREP_CIF_VAR', '1')] - libraries += ['ffi'] - else: - use_pkg_config() + use_pkg_config() ask_supports_thread() ask_supports_sync_synchronize() +if 'darwin' in sys.platform: + # priority is given to `pkg_config`, but always fall back on SDK's libffi. + extra_compile_args += ['-iwithsysroot/usr/include/ffi'] + if 'freebsd' in sys.platform: include_dirs.append('/usr/local/include') library_dirs.append('/usr/local/lib') -if 'darwin' in sys.platform: - try: - p = subprocess.Popen(['xcrun', '--show-sdk-path'], - stdout=subprocess.PIPE) - except OSError as e: - if e.errno not in [errno.ENOENT, errno.EACCES]: - raise - else: - t = p.stdout.read().decode().strip() - p.stdout.close() - if p.wait() == 0: - include_dirs.append(t + '/usr/include/ffi') - - - if __name__ == '__main__': from setuptools import setup, Distribution, Extension |