bpo-36146: Fix inc_dirs in setup.py on macOS (GH-12098)

Fix setup.py on macOS: only add /usr/include/ffi to include
directories of _ctypes, not for all extensions.
This commit is contained in:
Victor Stinner 2019-03-01 13:53:46 +01:00 committed by GitHub
parent 62be763348
commit 96d81583be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -0,0 +1,2 @@
Fix setup.py on macOS: only add ``/usr/include/ffi`` to include
directories of _ctypes, not for all extensions.

View File

@ -2003,16 +2003,17 @@ class PyBuildExt(build_ext):
libraries=['m'])
self.extensions.extend([ext, ext_test])
ffi_inc_dirs = inc_dirs.copy()
if MACOS:
if '--with-system-ffi' not in sysconfig.get_config_var("CONFIG_ARGS"):
return
# OS X 10.5 comes with libffi.dylib; the include files are
# in /usr/include/ffi
inc_dirs.append('/usr/include/ffi')
ffi_inc_dirs.append('/usr/include/ffi')
ffi_inc = [sysconfig.get_config_var("LIBFFI_INCLUDEDIR")]
if not ffi_inc or ffi_inc[0] == '':
ffi_inc = find_file('ffi.h', [], inc_dirs)
ffi_inc = find_file('ffi.h', [], ffi_inc_dirs)
if ffi_inc is not None:
ffi_h = ffi_inc[0] + '/ffi.h'
if not os.path.exists(ffi_h):