Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile.pre.in
Original file line numberDiff line numberDiff line change
Expand Up@@ -305,6 +305,7 @@ IO_OBJS= \
##########################################################################

LIBFFI_INCLUDEDIR= @LIBFFI_INCLUDEDIR@
LIBFFI_LIBDIR= @LIBFFI_LIBDIR@

##########################################################################
# Parser
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Fix issues with building python with a non-system version of libffi.
4 changes: 4 additions & 0 deletions configure
Original file line numberDiff line numberDiff line change
Expand Up@@ -660,6 +660,7 @@ DFLAGS
DTRACE
TCLTK_LIBS
TCLTK_INCLUDES
LIBFFI_LIBDIR
LIBFFI_INCLUDEDIR
PKG_CONFIG_LIBDIR
PKG_CONFIG_PATH
Expand DownExpand Up@@ -10632,11 +10633,14 @@ fi

if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG" then
LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
LIBFFI_LIBDIR="`"$PKG_CONFIG" libffi --libs-only-L 2>/dev/null | sed -e 's/^-L//;s/ *$//'`"
else
LIBFFI_INCLUDEDIR=""
LIBFFI_LIBDIR=""
fi



# Check for use of the system libmpdec library
{$as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-system-libmpdec" >&5
$as_echo_n "checking for --with-system-libmpdec... " >&6}
Expand Down
3 changes: 3 additions & 0 deletions configure.ac
Original file line numberDiff line numberDiff line change
Expand Up@@ -3097,10 +3097,13 @@ fi

if test "$with_system_ffi" = "yes" && test -n "$PKG_CONFIG" then
LIBFFI_INCLUDEDIR="`"$PKG_CONFIG" libffi --cflags-only-I 2>/dev/null | sed -e 's/^-I//;s/ *$//'`"
LIBFFI_LIBDIR="`"$PKG_CONFIG" libffi --libs-only-L 2>/dev/null | sed -e 's/^-L//;s/ *$//'`"
else
LIBFFI_INCLUDEDIR=""
LIBFFI_LIBDIR=""
fi
AC_SUBST(LIBFFI_INCLUDEDIR)
AC_SUBST(LIBFFI_LIBDIR)

# Check for use of the system libmpdec library
AC_MSG_CHECKING(for --with-system-libmpdec)
Expand Down
25 changes: 20 additions & 5 deletions setup.py
Original file line numberDiff line numberDiff line change
Expand Up@@ -2236,7 +2236,9 @@ def detect_ctypes(self):
libraries=['m']))

ffi_inc = sysconfig.get_config_var("LIBFFI_INCLUDEDIR")
ffi_lib = None

# Potential names of the library (e.g. libNAME.{so,dylib})
ffi_libname_candidates = ('ffi', 'ffi_pic')

ffi_inc_dirs = self.inc_dirs.copy()
if MACOS:
Expand All@@ -2246,7 +2248,7 @@ def detect_ctypes(self):
if os.path.exists(ffi_in_sdk):
ext.extra_compile_args.append("-DUSING_APPLE_OS_LIBFFI=1")
ffi_inc = ffi_in_sdk
ffi_lib = 'ffi'
ffi_libname_candidates = ('ffi',)
else:
# OS X 10.5 comes with libffi.dylib; the include files are
# in /usr/include/ffi
Expand All@@ -2261,10 +2263,21 @@ def detect_ctypes(self):
if not os.path.exists(ffi_h):
ffi_inc = None
print('Header file{} does not exist'.format(ffi_h))
if ffi_lib is None and ffi_inc:
for lib_name in ('ffi', 'ffi_pic'):
if (self.compiler.find_library_file(self.lib_dirs, lib_name)):

ffi_lib = None
# Then we probably also need to figure out the path to the
# library too.
if ffi_inc:
# A list containing nothing or the directory from the
# configure script.
maybe_ffi_libdir = [d for d in [sysconfig.get_config_var("LIBFFI_LIBDIR")]
if os.path.isdir(d)]

for lib_name in ffi_libname_candidates:
fullpath = self.compiler.find_library_file(self.lib_dirs + maybe_ffi_libdir, lib_name)
if fullpath:
ffi_lib = lib_name
ffi_libdir = os.path.normpath(os.path.dirname(fullpath))
break

if ffi_inc and ffi_lib:
Expand All@@ -2278,6 +2291,8 @@ def detect_ctypes(self):

ext.include_dirs.append(ffi_inc)
ext.libraries.append(ffi_lib)
if ffi_libdir not in self.lib_dirs:
ext.library_dirs.append(ffi_libdir)
self.use_system_libffi = True

if sysconfig.get_config_var('HAVE_LIBDL'):
Expand Down